]> Git Repo - uclibc-ng.git/commitdiff
Miscellaneous tidying-up.
authorMiles Bader <[email protected]>
Thu, 25 Jul 2002 04:23:28 +0000 (04:23 -0000)
committerMiles Bader <[email protected]>
Thu, 25 Jul 2002 04:23:28 +0000 (04:23 -0000)
libc/stdlib/malloc/free.c
libc/stdlib/malloc/malloc.c

index f7d8fc18d62564d1a147ab0c6df5d4bcd757e28d..3074ff5e6c184b166a6ccd4a3af92770e8faac5a 100644 (file)
@@ -18,7 +18,7 @@
 #include "malloc.h"
 #include "heap.h"
 
-\f
+
 void
 free (void *mem)
 {
@@ -35,23 +35,23 @@ free (void *mem)
 
       __malloc_lock ();
 
+      /* Put MEM back in the heap, and get the free-area it was placed in.  */
       fa = __heap_free (&__malloc_heap, mem, size);
 
-      /* Now we check to see if FA has grown big enough that it should be
+      /* See if the free-area FA has grown big enough that it should be
         unmapped.  */
       if (HEAP_FREE_AREA_SIZE (fa) < MALLOC_UNMAP_THRESHOLD)
-       /* Nothing left to do, just release the lock.  */
+       /* Nope, nothing left to do, just release the lock.  */
        __malloc_unlock ();
       else
-       /* Try to unmap FA.  */
+       /* Yup, try to unmap FA.  */
        {
-         unsigned long start, end;
+         unsigned long start = (unsigned long)HEAP_FREE_AREA_START (fa);
+         unsigned long end = (unsigned long)HEAP_FREE_AREA_END (fa);
 #ifndef MALLOC_USE_SBRK
          unsigned long unmap_start, unmap_end;
 #endif
 
-         end = (unsigned long)HEAP_FREE_AREA_END (fa);
-
 #ifdef MALLOC_USE_SBRK
          /* Get the sbrk lock so that the two possible calls to sbrk below
             are guaranteed to be contiguous.  */
@@ -68,17 +68,13 @@ free (void *mem)
          if ((void *)end != sbrk (0))
            {
              MALLOC_DEBUG ("  not unmapping: 0x%lx - 0x%lx (%d bytes)\n",
-                           (unsigned long)HEAP_FREE_AREA_START (fa),
-                           (unsigned long)HEAP_FREE_AREA_END (fa),
-                           fa->size);
+                           start, end, end - start);
              __malloc_unlock_sbrk ();
              __malloc_unlock ();
              return;
            }
 #endif
 
-         start = (unsigned long)HEAP_FREE_AREA_START (fa);
-
          MALLOC_DEBUG ("  unmapping: 0x%lx - 0x%lx (%ld bytes)\n",
                        start, end, end - start);
 
@@ -136,6 +132,7 @@ free (void *mem)
          __malloc_unlock ();
 
          if (unmap_end > unmap_start)
+           /* Finally, actually unmap the memory.  */
            munmap ((void *)unmap_start, unmap_end - unmap_start);
 
 #endif /* MALLOC_USE_SBRK */
index e6b9c0d664459720b3e0b79d8b81b00bd4edde8e..2ec12218c25142a81a213d589ac5027446191ae1 100644 (file)
@@ -31,7 +31,7 @@ malloc_mutex_t __malloc_sbrk_lock;
 # endif /* MALLOC_USE_SBRK */
 #endif /* MALLOC_USE_LOCKING */
 
-\f
+
 void *
 malloc (size_t size)
 {
This page took 0.028808 seconds and 4 git commands to generate.