From 20a954716e5709ec575f8773f596a1603f27d342 Mon Sep 17 00:00:00 2001 From: pjht Date: Mon, 22 Apr 2019 13:18:05 -0500 Subject: [PATCH] Change malloc definition to use size_t --- libc/stdlib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libc/stdlib.c b/libc/stdlib.c index fc65750..c10b4fc 100644 --- a/libc/stdlib.c +++ b/libc/stdlib.c @@ -52,7 +52,7 @@ static void reserve_block(uint32_t mem_blks) { num_used_entries++; } -void* malloc(uint32_t size) { +void* malloc(size_t size) { uint32_t num_4b_grps=(uint32_t)ceilf((float)size/4); num_4b_grps+=3; int blk_indx=-1; @@ -130,7 +130,7 @@ void* realloc(void *mem, size_t new_sz) { if (mem==NULL) { return ptr; } - uint32_t num_4b_grps=*((uint32_t*)((uint32_t)mem-12)); + uint32_t num_4b_grps=*((uint32_t*)((char*)mem-12)); memcpy(ptr,mem,num_4b_grps*4); free(mem); mem=ptr; @@ -138,7 +138,7 @@ void* realloc(void *mem, size_t new_sz) { } void free(void* mem) { - uint32_t* info=(uint32_t*)((uint32_t)mem-12); + uint32_t* info=(uint32_t*)((char*)mem-12); uint32_t num_4b_grps=info[0]; uint32_t bmap_index=info[1]; uint32_t blk_indx=info[2];