|
@@ -18,7 +18,7 @@
|
|
|
#include "malloc.h"
|
|
|
#include "heap.h"
|
|
|
|
|
|
-
|
|
|
+
|
|
|
void
|
|
|
free (void *mem)
|
|
|
{
|
|
@@ -35,23 +35,23 @@ free (void *mem)
|
|
|
|
|
|
__malloc_lock ();
|
|
|
|
|
|
+
|
|
|
fa = __heap_free (&__malloc_heap, mem, size);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
unmapped. */
|
|
|
if (HEAP_FREE_AREA_SIZE (fa) < MALLOC_UNMAP_THRESHOLD)
|
|
|
-
|
|
|
+
|
|
|
__malloc_unlock ();
|
|
|
else
|
|
|
-
|
|
|
+
|
|
|
{
|
|
|
- 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
|
|
|
|
|
|
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)
|
|
|
+
|
|
|
munmap ((void *)unmap_start, unmap_end - unmap_start);
|
|
|
|
|
|
#endif
|