I'm a bit overwhelmed at this line specifically:
Entry** newHeap = (Entry**)malloc(sizeof(Entry*) * newHeapLength);
in this code:
/**
* Expands the heap array of the given priority queue by
* replacing it with another that is double its size.
*
* @param pq the priority queue whose heap is to be doubled in size
* return 1 for successful expansion or an error code:
*/
int expandHeap (PriorityQueue *pq)
{
int returnCode = 1;
int newHeapLength = pq->heapLength * 2;
Entry** newHeap = (Entry**)malloc(sizeof(Entry*) * newHeapLength);
if (newHeap != NULL)
{
int index;
for (index = 0; index < pq->heapLength; index++)
{
newHeap[index] = pq->heap[index];
}
free(pq->heap);
pq->heap = newHeap;
pq->heapLength = newHeapLength;
}
else
{
returnCode = -1; // TODO: make meaningful error codes
}
return returnCode;
}