mirror of
https://github.com/ToyB-Chan/minimal-heap.git
synced 2026-07-13 21:51:16 +02:00
removed TotalOccupiedSize stats because of inaccuracy
This commit is contained in:
@@ -58,7 +58,6 @@ typedef struct _MIHP_HeapStats
|
|||||||
size_t NumTotalSegments;
|
size_t NumTotalSegments;
|
||||||
size_t NumTotalOccupiedSegments;
|
size_t NumTotalOccupiedSegments;
|
||||||
size_t TotalSize;
|
size_t TotalSize;
|
||||||
size_t TotalOccupiedSize;
|
|
||||||
} MIHP_HeapStats;
|
} MIHP_HeapStats;
|
||||||
|
|
||||||
// This structs size must be multiple of 8
|
// This structs size must be multiple of 8
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ void* MIHP_Allocate(MIHP_Heap* heap, size_t size)
|
|||||||
currentArea->Checksum = MIHP_GenerateHeapMemoryAreaChecksum(currentArea);
|
currentArea->Checksum = MIHP_GenerateHeapMemoryAreaChecksum(currentArea);
|
||||||
|
|
||||||
heap->Stats.NumTotalOccupiedSegments++;
|
heap->Stats.NumTotalOccupiedSegments++;
|
||||||
heap->Stats.TotalOccupiedSize += targetSegment->OccupiedSize;
|
|
||||||
heap->LastSuccessfulAllocationArea = currentArea;
|
heap->LastSuccessfulAllocationArea = currentArea;
|
||||||
|
|
||||||
MIHP_UNLOCK_HEAP(&heap->HeapLock);
|
MIHP_UNLOCK_HEAP(&heap->HeapLock);
|
||||||
@@ -251,8 +250,6 @@ bool MIHP_Free(MIHP_Heap* heap, void* ptr)
|
|||||||
MIHP_HeapMemoryAreaHeader* area = segment->OwningMemoryArea;
|
MIHP_HeapMemoryAreaHeader* area = segment->OwningMemoryArea;
|
||||||
MIHP_ValidateHeapMemoryAreaHeader(heap, area);
|
MIHP_ValidateHeapMemoryAreaHeader(heap, area);
|
||||||
|
|
||||||
size_t occupiedSize = segment->OccupiedSize;
|
|
||||||
|
|
||||||
segment->OccupiedSize = 0;
|
segment->OccupiedSize = 0;
|
||||||
segment->Checksum = MIHP_GenerateHeapSegmentChecksum(segment);
|
segment->Checksum = MIHP_GenerateHeapSegmentChecksum(segment);
|
||||||
|
|
||||||
@@ -260,7 +257,6 @@ bool MIHP_Free(MIHP_Heap* heap, void* ptr)
|
|||||||
area->Checksum = MIHP_GenerateHeapMemoryAreaChecksum(area);
|
area->Checksum = MIHP_GenerateHeapMemoryAreaChecksum(area);
|
||||||
|
|
||||||
heap->Stats.NumTotalOccupiedSegments--;
|
heap->Stats.NumTotalOccupiedSegments--;
|
||||||
heap->Stats.TotalOccupiedSize -= occupiedSize;
|
|
||||||
|
|
||||||
if (area->NumOccupiedSegments == 0 && heap->Stats.NumMemoryAreas > 1)
|
if (area->NumOccupiedSegments == 0 && heap->Stats.NumMemoryAreas > 1)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user