From 2fbc5f2c9c7eb68af76c745d19817f78200df410 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 30 Jul 2002 09:51:02 +0000 Subject: Make sure NEW_SIZE is a multiple of HEAP_GRANULARITY. Calculate amount freed when shrinking correctly. --- libc/stdlib/malloc/realloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libc/stdlib/malloc/realloc.c') diff --git a/libc/stdlib/malloc/realloc.c b/libc/stdlib/malloc/realloc.c index dbcb19ebe..e8906422d 100644 --- a/libc/stdlib/malloc/realloc.c +++ b/libc/stdlib/malloc/realloc.c @@ -30,7 +30,7 @@ realloc (void *mem, size_t new_size) /* Make sure that we're dealing in a multiple of the heap allocation unit (SIZE is already guaranteed to be so). */ - // new_size = HEAP_ADJUST_SIZE (new_size); + new_size = HEAP_ADJUST_SIZE (new_size); MALLOC_DEBUG ("realloc: 0x%lx, %d (base = 0x%lx, total_size = %d)\n", (long)mem, new_size, (long)base_mem, size); @@ -64,7 +64,7 @@ realloc (void *mem, size_t new_size) /* Shrink the block. */ { __malloc_lock (); - __heap_free (&__malloc_heap, base_mem + new_size, new_size - size); + __heap_free (&__malloc_heap, base_mem + new_size, size - new_size); __malloc_unlock (); MALLOC_SET_SIZE (mem, new_size); } -- cgit v1.2.3