From ee7ec20503558510377023a090bb36b19f7eebd3 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Thu, 22 Oct 2009 13:06:15 +0000 Subject: [PATCH] Account for single page allocations. They aren't used anywhere right now because the bin sizes ensure that when hitting this case it always allocates multiple pages. This makes it more flexible for other use cases though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33726 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/heap.cpp | 8 +++++--- src/system/libroot/posix/malloc_debug/heap.cpp | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/system/kernel/heap.cpp b/src/system/kernel/heap.cpp index 45afcde207..59f3e257bd 100644 --- a/src/system/kernel/heap.cpp +++ b/src/system/kernel/heap.cpp @@ -1296,13 +1296,15 @@ heap_allocate_contiguous_pages(heap_allocator *heap, uint32 pageCount) continue; } - if (first > 0) { + if (first < 0) + first = i; + + if (first >= 0) { if ((i + 1 - first) == pageCount) { found = true; break; } - } else - first = i; + } } if (!found) { diff --git a/src/system/libroot/posix/malloc_debug/heap.cpp b/src/system/libroot/posix/malloc_debug/heap.cpp index c25a807156..1e3d0b9eb1 100644 --- a/src/system/libroot/posix/malloc_debug/heap.cpp +++ b/src/system/libroot/posix/malloc_debug/heap.cpp @@ -925,13 +925,15 @@ heap_allocate_contiguous_pages(heap_allocator *heap, uint32 pageCount) continue; } - if (first > 0) { + if (first < 0) + first = i; + + if (first >= 0) { if ((i + 1 - first) == pageCount) { found = true; break; } - } else - first = i; + } } if (!found) {