diff options
Diffstat (limited to 'libc/stdlib/malloc/free.c')
-rw-r--r-- | libc/stdlib/malloc/free.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/libc/stdlib/malloc/free.c b/libc/stdlib/malloc/free.c index da395331b..fd29690ad 100644 --- a/libc/stdlib/malloc/free.c +++ b/libc/stdlib/malloc/free.c @@ -22,7 +22,7 @@ libc_hidden_proto(sbrk) #include "heap.h" static void -free_to_heap (void *mem, struct heap *heap) +free_to_heap (void *mem, struct heap_free_area *heap, malloc_mutex_t *heap_lock) { size_t size; struct heap_free_area *fa; @@ -39,7 +39,7 @@ free_to_heap (void *mem, struct heap *heap) size = MALLOC_SIZE (mem); mem = MALLOC_BASE (mem); - __heap_lock (heap); + __pthread_mutex_lock (heap_lock); /* Put MEM back in the heap, and get the free-area it was placed in. */ fa = __heap_free (heap, mem, size); @@ -48,7 +48,7 @@ free_to_heap (void *mem, struct heap *heap) unmapped. */ if (HEAP_FREE_AREA_SIZE (fa) < MALLOC_UNMAP_THRESHOLD) /* Nope, nothing left to do, just release the lock. */ - __heap_unlock (heap); + __pthread_mutex_unlock (heap_lock); else /* Yup, try to unmap FA. */ { @@ -81,7 +81,7 @@ free_to_heap (void *mem, struct heap *heap) MALLOC_DEBUG (-1, "not unmapping: 0x%lx - 0x%lx (%ld bytes)", start, end, end - start); __malloc_unlock_sbrk (); - __heap_unlock (heap); + __pthread_mutex_unlock (heap_lock); return; } #endif @@ -108,7 +108,7 @@ free_to_heap (void *mem, struct heap *heap) #ifdef MALLOC_USE_SBRK /* Release the heap lock; we're still holding the sbrk lock. */ - __heap_unlock (heap); + __pthread_mutex_unlock (heap_lock); /* Lower the brk. */ sbrk (start - end); /* Release the sbrk lock too; now we hold no locks. */ @@ -172,15 +172,15 @@ free_to_heap (void *mem, struct heap *heap) /* We have to unlock the heap before we recurse to free the mmb descriptor, because we might be unmapping from the mmb heap. */ - __heap_unlock (heap); + __pthread_mutex_unlock (heap_lock); /* Release the descriptor block we used. */ - free_to_heap (mmb, &__malloc_mmb_heap); + free_to_heap (mmb, &__malloc_mmb_heap, &__malloc_mmb_heap_lock); /* Do the actual munmap. */ munmap ((void *)mmb_start, mmb_end - mmb_start); - __heap_lock (heap); + __pthread_mutex_lock (heap_lock); # ifdef __UCLIBC_HAS_THREADS__ /* In a multi-threaded program, it's possible that PREV_MMB has @@ -213,7 +213,7 @@ free_to_heap (void *mem, struct heap *heap) } /* Finally release the lock for good. */ - __heap_unlock (heap); + __pthread_mutex_unlock (heap_lock); MALLOC_MMB_DEBUG_INDENT (-1); @@ -243,7 +243,7 @@ free_to_heap (void *mem, struct heap *heap) } /* Release the heap lock before we do the system call. */ - __heap_unlock (heap); + __pthread_mutex_unlock (heap_lock); if (unmap_end > unmap_start) /* Finally, actually unmap the memory. */ @@ -260,5 +260,5 @@ free_to_heap (void *mem, struct heap *heap) void free (void *mem) { - free_to_heap (mem, &__malloc_heap); + free_to_heap (mem, __malloc_heap, &__malloc_heap_lock); } |