* @brief Destroy the priority queue and release all memory it owns. * * Frees both the underlying vector AND the PriorityQueue header. * NULL-safe. * * @param pq Queue to destroy. Pass NULL for a no-op. */
| 351 | * @param pq Queue to destroy. Pass NULL for a no-op. |
| 352 | */ |
| 353 | void priority_queue_deallocate(PriorityQueue* pq) { |
| 354 | PQUEUE_LOG("[priority_queue_deallocate]: enter pq=%p", (void*)pq); |
| 355 | if (!pq) { |
| 356 | PQUEUE_LOG("[priority_queue_deallocate]: NULL receiver, no-op"); |
| 357 | return; |
| 358 | } |
| 359 | if (pq->vec) { |
| 360 | PQUEUE_LOG("[priority_queue_deallocate]: freeing vec=%p", (void*)pq->vec); |
| 361 | vector_deallocate(pq->vec); |
| 362 | pq->vec = NULL; |
| 363 | } |
| 364 | free(pq); |
| 365 | PQUEUE_LOG("[priority_queue_deallocate]: exit (queue header freed)"); |
| 366 | } |
| 367 | |
| 368 | |
| 369 | /** |
no test coverage detected