diff --git a/minimal_heap.h b/minimal_heap.h index e995dfb..268a840 100644 --- a/minimal_heap.h +++ b/minimal_heap.h @@ -146,7 +146,7 @@ bool MIHP_MergeHeaps(MIHP_Heap* sourceHeap, MIHP_Heap* heapToAbsorb); bool MIHP_IsPointerInHeap(MIHP_Heap* heap, void* ptr); size_t MIHP_GetPtrAllocationSize(MIHP_Heap* heap, void* ptr); -void MIHP_ValidateHeap(MIHP_Heap* heap); +bool MIHP_ValidateHeap(MIHP_Heap* heap); typedef void(MIHP_WalkHeapCallbackFn)(const MIHP_Heap* heap, const MIHP_HeapMemoryAreaHeader* area, const MIHP_HeapSegmentHeader* segment); diff --git a/minimal_heap_implementation.inl b/minimal_heap_implementation.inl index 64fe6f4..5a3c802 100644 --- a/minimal_heap_implementation.inl +++ b/minimal_heap_implementation.inl @@ -497,11 +497,14 @@ size_t MIHP_GetPtrAllocationSize(MIHP_Heap* heap, void* ptr) return segment->OccupiedSize; } -void MIHP_ValidateHeap(MIHP_Heap* heap) +bool MIHP_ValidateHeap(MIHP_Heap* heap) { if (!MIHP_IsHeapInitialized(heap)) return false; + if (heap->Config.HeapValidationMode == MIHP_HVM_None) + return false; + MIHP_LockHeap(heap); MIHP_HeapMemoryAreaHeader* nextArea = heap->FirstArea; @@ -521,6 +524,7 @@ void MIHP_ValidateHeap(MIHP_Heap* heap) } MIHP_UnlockHeap(heap); + return true; } bool MIHP_WalkHeap(MIHP_Heap* heap, MIHP_WalkHeapCallbackFn* callback)