mirror of
https://github.com/ToyB-Chan/minimal-heap.git
synced 2026-07-13 21:51:16 +02:00
changed the order areas are traversed
This commit is contained in:
@@ -25,8 +25,8 @@
|
||||
#define MIHP_MIN_TRAVERSELS_BEFORE_EXPANSION 10000
|
||||
#endif
|
||||
|
||||
#ifndef MIHP_EXPANSION_TRAVERSEL_OCCUPIED_INT_PERCENT
|
||||
#define MIHP_EXPANSION_TRAVERSEL_OCCUPIED_INT_PERCENT 50
|
||||
#ifndef MIHP_MIN_EXPANSION_TRAVERSEL_OCCUPIED_INT_PERCENT
|
||||
#define MIHP_MIN_EXPANSION_TRAVERSEL_OCCUPIED_INT_PERCENT 50
|
||||
#endif
|
||||
|
||||
#ifndef MIHP_ASSERT
|
||||
|
||||
@@ -85,20 +85,13 @@ void* MIHP_Allocate(MIHP_Heap* heap, size_t size)
|
||||
|
||||
bool triedLastAllocationArea = false;
|
||||
MIHP_HeapMemoryAreaHeader* nextArea = heap->FirstArea;
|
||||
while (nextArea)
|
||||
do
|
||||
{
|
||||
MIHP_HeapMemoryAreaHeader* currentArea = NULL;
|
||||
|
||||
if (!triedLastAllocationArea)
|
||||
{
|
||||
currentArea = heap->LastSuccessfulAllocationArea;
|
||||
triedLastAllocationArea = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentArea = nextArea;
|
||||
MIHP_HeapMemoryAreaHeader* currentArea = nextArea;
|
||||
nextArea = currentArea->NextArea;
|
||||
}
|
||||
|
||||
if (nextArea == NULL)
|
||||
nextArea = heap->FirstArea;
|
||||
|
||||
MIHP_ValidateHeapMemoryAreaHeader(heap, currentArea);
|
||||
|
||||
@@ -147,7 +140,7 @@ void* MIHP_Allocate(MIHP_Heap* heap, size_t size)
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
} while (nextArea != heap->LastSuccessfulAllocationArea);
|
||||
|
||||
AllocateNewArea:
|
||||
size_t newAreaSize = heap->Stats.TotalSize;
|
||||
|
||||
Reference in New Issue
Block a user