mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Add function for freeing binary heap.
This commit is contained in:
parent
b1fa5f6d34
commit
773ddd98a8
2 changed files with 40 additions and 0 deletions
|
|
@ -645,3 +645,27 @@ size_t K_BHeapContains(bheap_t *const heap, void *const data, size_t index)
|
||||||
|
|
||||||
return heapindexwithdata;
|
return heapindexwithdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean K_BHeapFree(bheap_t *const heap)
|
||||||
|
{
|
||||||
|
boolean freesuccess = false;
|
||||||
|
|
||||||
|
if (heap == NULL)
|
||||||
|
{
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "NULL heap in K_BHeapFree.\n");
|
||||||
|
}
|
||||||
|
else if (!K_BHeapValid(heap))
|
||||||
|
{
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Uninitialised heap in K_BHeapFree.\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Z_Free(heap->array);
|
||||||
|
heap->array = NULL;
|
||||||
|
heap->capacity = 0U;
|
||||||
|
heap->count = 0U;
|
||||||
|
freesuccess = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return freesuccess;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,4 +122,20 @@ boolean K_UpdateBHeapItemValue(bheapitem_t *const item, const UINT32 newvalue);
|
||||||
|
|
||||||
size_t K_BHeapContains(bheap_t *const heap, void *const data, size_t index);
|
size_t K_BHeapContains(bheap_t *const heap, void *const data, size_t index);
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------
|
||||||
|
boolean K_BHeapFree(bheap_t *const heap)
|
||||||
|
|
||||||
|
Free the binary heap.
|
||||||
|
This does NOT free the data held within the binary heap items. Make sure those can still be freed manually.
|
||||||
|
|
||||||
|
Input Arguments:-
|
||||||
|
heap - The heap to free
|
||||||
|
|
||||||
|
Return:-
|
||||||
|
True if the heap was freed successfully, false if the heap wasn't valid to free
|
||||||
|
--------------------------------------------------*/
|
||||||
|
|
||||||
|
boolean K_BHeapFree(bheap_t *const heap);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue