diff options
author | Miles Bader <miles@lsi.nec.co.jp> | 2002-07-30 09:51:02 +0000 |
---|---|---|
committer | Miles Bader <miles@lsi.nec.co.jp> | 2002-07-30 09:51:02 +0000 |
commit | 2fbc5f2c9c7eb68af76c745d19817f78200df410 (patch) | |
tree | 3373c5c00f32eea5b9a1298a14e1fe41a63e89b1 | |
parent | 9f86edc4a9ef5762c03b7dc42d127c031c16483c (diff) |
Make sure NEW_SIZE is a multiple of HEAP_GRANULARITY.
Calculate amount freed when shrinking correctly.
-rw-r--r-- | libc/stdlib/malloc/realloc.c | 4 |
1 files changed, 2 insertions, 2 deletions
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); } |