From 65411f56b753b38daa897b6982bfa6f289180951 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Mon, 17 Aug 2009 22:51:01 +0000 Subject: [PATCH] We can return directly as we use handy locker objects. Adjusted and added comments. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32483 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/heap.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/system/kernel/heap.cpp b/src/system/kernel/heap.cpp index 64c9b618b7..a8d0ccf167 100644 --- a/src/system/kernel/heap.cpp +++ b/src/system/kernel/heap.cpp @@ -1462,12 +1462,12 @@ heap_free(heap_allocator *heap, void *address) // smaller than our address to become our only candidate for freeing if (area->base <= (addr_t)address) { if ((addr_t)address >= area->base + area->size) { - // the only candidate area doesn't contain the address, - // set it to NULL so we return below (none of the other areas - // can contain the address as the list is ordered) - area = NULL; + // none of the other areas can contain the address as the list + // is ordered + return B_ENTRY_NOT_FOUND; } + // this area contains the allocation, we're done searching break; } @@ -1621,7 +1621,7 @@ static status_t heap_realloc(heap_allocator *heap, void *address, void **newAddress, size_t newSize) { - ReadLocker heapReadLocker(heap->area_lock); + ReadLocker areaReadLocker(heap->area_lock); heap_area *area = heap->all_areas; while (area) { // since the all_areas list is ordered by base with the biggest @@ -1630,12 +1630,12 @@ heap_realloc(heap_allocator *heap, void *address, void **newAddress, // reallocating if (area->base <= (addr_t)address) { if ((addr_t)address >= area->base + area->size) { - // the only candidate area doesn't contain the address, - // set it to NULL so we return below (none of the other areas - // can contain the address as the list is ordered) - area = NULL; + // none of the other areas can contain the address as the list + // is ordered + return B_ENTRY_NOT_FOUND; } + // this area contains the allocation, we're done searching break; } @@ -1683,7 +1683,7 @@ heap_realloc(heap_allocator *heap, void *address, void **newAddress, } } - heapReadLocker.Unlock(); + areaReadLocker.Unlock(); #if KERNEL_HEAP_LEAK_CHECK newSize += sizeof(heap_leak_check_info);