mirror of
https://github.com/ToyB-Chan/minimal-heap.git
synced 2026-07-13 21:51:16 +02:00
rename and fixed missing unlock
This commit is contained in:
@@ -124,7 +124,7 @@ bool MIHP_IsHeapInitialized(const MIHP_Heap* heap);
|
|||||||
bool MIHP_UninitializeHeap(MIHP_Heap* heap, bool force);
|
bool MIHP_UninitializeHeap(MIHP_Heap* heap, bool force);
|
||||||
|
|
||||||
void* MIHP_Allocate(MIHP_Heap* heap, size_t size);
|
void* MIHP_Allocate(MIHP_Heap* heap, size_t size);
|
||||||
void* MIHP_Realloc(MIHP_Heap* heap, void* ptr, size_t newSize);
|
void* MIHP_Reallocate(MIHP_Heap* heap, void* ptr, size_t newSize);
|
||||||
bool MIHP_Free(MIHP_Heap* heap, void* ptr);
|
bool MIHP_Free(MIHP_Heap* heap, void* ptr);
|
||||||
|
|
||||||
bool MIHP_IsPointerInHeap(MIHP_Heap* heap, void* ptr);
|
bool MIHP_IsPointerInHeap(MIHP_Heap* heap, void* ptr);
|
||||||
|
|||||||
@@ -150,7 +150,10 @@ AllocateNewArea:
|
|||||||
|
|
||||||
MIHP_HeapMemoryAreaHeader* newArea = MIHP_CreateHeapMemoryArea(heap, newAreaSize);
|
MIHP_HeapMemoryAreaHeader* newArea = MIHP_CreateHeapMemoryArea(heap, newAreaSize);
|
||||||
if (newArea == NULL)
|
if (newArea == NULL)
|
||||||
|
{
|
||||||
|
MIHP_UNLOCK_HEAP(&heap->HeapLock);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
newArea->NextArea = heap->FirstArea;
|
newArea->NextArea = heap->FirstArea;
|
||||||
heap->FirstArea->PreviousArea = newArea;
|
heap->FirstArea->PreviousArea = newArea;
|
||||||
@@ -164,7 +167,7 @@ AllocateNewArea:
|
|||||||
return MIHP_Allocate(heap, size);
|
return MIHP_Allocate(heap, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* MIHP_Realloc(MIHP_Heap* heap, void* ptr, size_t newSize)
|
void* MIHP_Reallocate(MIHP_Heap* heap, void* ptr, size_t newSize)
|
||||||
{
|
{
|
||||||
if (newSize == 0)
|
if (newSize == 0)
|
||||||
{
|
{
|
||||||
@@ -203,7 +206,7 @@ void* MIHP_Realloc(MIHP_Heap* heap, void* ptr, size_t newSize)
|
|||||||
if (segment->NextSegment && MIHP_MergeHeapSegments(segment, segment->NextSegment))
|
if (segment->NextSegment && MIHP_MergeHeapSegments(segment, segment->NextSegment))
|
||||||
{
|
{
|
||||||
MIHP_UNLOCK_HEAP(&heap->HeapLock);
|
MIHP_UNLOCK_HEAP(&heap->HeapLock);
|
||||||
return MIHP_Realloc(heap, ptr, newSize);
|
return MIHP_Reallocate(heap, ptr, newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
MIHP_UNLOCK_HEAP(&heap->HeapLock);
|
MIHP_UNLOCK_HEAP(&heap->HeapLock);
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ int main()
|
|||||||
#if USE_MALLOC
|
#if USE_MALLOC
|
||||||
myptrs[i] = realloc(myptrs[i], size);
|
myptrs[i] = realloc(myptrs[i], size);
|
||||||
#else
|
#else
|
||||||
myptrs[i] = MIHP_Realloc(&myHeap, myptrs[i], size);
|
myptrs[i] = MIHP_Reallocate(&myHeap, myptrs[i], size);
|
||||||
MIHP_ValidateHeap(&myHeap);
|
MIHP_ValidateHeap(&myHeap);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user