changed the order areas are traversed

This commit is contained in:
2026-06-09 19:41:06 +02:00
parent 3582e21a84
commit 2150fcb0a2
2 changed files with 8 additions and 15 deletions

View File

@@ -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

View File

@@ -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;
MIHP_HeapMemoryAreaHeader* currentArea = nextArea;
nextArea = currentArea->NextArea;
if (!triedLastAllocationArea)
{
currentArea = heap->LastSuccessfulAllocationArea;
triedLastAllocationArea = true;
}
else
{
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;