summaryrefslogtreecommitdiff
path: root/userland/libc/malloc/malloc.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2023-11-23 00:52:35 +0100
committerAnton Kling <anton@kling.gg>2023-11-23 00:52:35 +0100
commit81819f711e6d1f9216f688da8ecbbc682d106d9c (patch)
tree0f0df7c43cc5bc956c2c067e55766bfa90823a7f /userland/libc/malloc/malloc.c
parentec91e81a4fcfd7ee6bc4150f06d8740e82f808da (diff)
LibC: Reduce warnings in code
Diffstat (limited to 'userland/libc/malloc/malloc.c')
-rw-r--r--userland/libc/malloc/malloc.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/userland/libc/malloc/malloc.c b/userland/libc/malloc/malloc.c
index 5c2fe98..4c9621b 100644
--- a/userland/libc/malloc/malloc.c
+++ b/userland/libc/malloc/malloc.c
@@ -1,6 +1,7 @@
#include <assert.h>
#include <errno.h>
#include <malloc/malloc.h>
+#include <math.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
@@ -21,10 +22,6 @@ typedef struct MallocHeader {
struct MallocHeader *n;
} MallocHeader;
-size_t max(size_t a, size_t b) { return (a > b) ? a : b; }
-
-//;size_t min(size_t a, size_t b) { return (a < b) ? a : b; }
-
uint64_t delta_page(uint64_t a) { return 0x1000 - (a % 0x1000); }
MallocHeader *head = NULL;
@@ -117,12 +114,6 @@ void merge_headers(MallocHeader *b) {
if (!n)
return;
- if (n > 0xf58c0820 - 0x8 && n < 0xf58c0820 + 0x8) {
- printf("b: %x\n", b);
- printf("b->n: %x\n", b->n);
- asm("hlt");
- assert(0);
- }
if (!(n->flags & IS_FREE))
return;
@@ -199,7 +190,7 @@ void *calloc(size_t nelem, size_t elsize) {
size_t get_mem_size(void *ptr) {
if (!ptr)
return 0;
- return ((MallocHeader *)(ptr - sizeof(MallocHeader)))->size;
+ return ((MallocHeader *)((u32)ptr - sizeof(MallocHeader)))->size;
}
void *realloc(void *ptr, size_t size) {