mirror of
https://github.com/ToyB-Chan/minimal-heap.git
synced 2026-07-13 21:51:16 +02:00
tweaked heuristics
This commit is contained in:
@@ -16,10 +16,19 @@
|
|||||||
#define MIHP_HEAP_STRUCTURE_VALIDATION_TYPE_CHECKSUM 2
|
#define MIHP_HEAP_STRUCTURE_VALIDATION_TYPE_CHECKSUM 2
|
||||||
|
|
||||||
/* Defines to be configured by the library user */
|
/* Defines to be configured by the library user */
|
||||||
|
|
||||||
#ifndef MIHP_HEAP_STRUCTURE_VALIDATION_TYPE
|
#ifndef MIHP_HEAP_STRUCTURE_VALIDATION_TYPE
|
||||||
#define MIHP_HEAP_STRUCTURE_VALIDATION_TYPE MIHP_HEAP_STRUCTURE_VALIDATION_TYPE_CHECKSUM
|
#define MIHP_HEAP_STRUCTURE_VALIDATION_TYPE MIHP_HEAP_STRUCTURE_VALIDATION_TYPE_CHECKSUM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MIHP_MIN_TRAVERSELS_BEFORE_EXPANSION
|
||||||
|
#define MIHP_MIN_TRAVERSELS_BEFORE_EXPANSION 10000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MIHP_EXPANSION_TRAVERSEL_OCCUPIED_INT_PERCENT
|
||||||
|
#define MIHP_EXPANSION_TRAVERSEL_OCCUPIED_INT_PERCENT 50
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MIHP_ASSERT
|
#ifndef MIHP_ASSERT
|
||||||
#define MIHP_ASSERT(Condition) while(1) { if (Condition) break; *(volatile char*)(0x0) = 0; }
|
#define MIHP_ASSERT(Condition) while(1) { if (Condition) break; *(volatile char*)(0x0) = 0; }
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ void* MIHP_Allocate(MIHP_Heap* heap, size_t size)
|
|||||||
MIHP_HeapSegmentHeader* nextSegment = currentArea->FirstSegment;
|
MIHP_HeapSegmentHeader* nextSegment = currentArea->FirstSegment;
|
||||||
while (nextSegment)
|
while (nextSegment)
|
||||||
{
|
{
|
||||||
if (numTraversedSegments * 100 > heap->Stats.NumTotalSegments * 80)
|
if (numTraversedSegments > MIHP_MIN_TRAVERSELS_BEFORE_EXPANSION)
|
||||||
|
if (numTraversedSegments * 100 > heap->Stats.NumTotalOccupiedSegments * MIHP_MIN_EXPANSION_TRAVERSEL_OCCUPIED_INT_PERCENT)
|
||||||
goto AllocateNewArea;
|
goto AllocateNewArea;
|
||||||
|
|
||||||
numTraversedSegments++;
|
numTraversedSegments++;
|
||||||
|
|||||||
Reference in New Issue
Block a user