]> Git Repo - uclibc-ng.git/commitdiff
Make sure NEW_SIZE is a multiple of HEAP_GRANULARITY.
authorMiles Bader <[email protected]>
Tue, 30 Jul 2002 09:51:02 +0000 (09:51 -0000)
committerMiles Bader <[email protected]>
Tue, 30 Jul 2002 09:51:02 +0000 (09:51 -0000)
Calculate amount freed when shrinking correctly.

libc/stdlib/malloc/realloc.c

index dbcb19ebe21f8c985e244fe35c0fd228b15370c0..e8906422d685b6b54af17231c79fd793cf662eeb 100644 (file)
@@ -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);
        }
This page took 0.026907 seconds and 4 git commands to generate.