* @brief Pre-allocate underlying storage for at least @p n elements. * * Useful before a tight bulk-push loop to avoid mid-loop reallocations * (each of which would invalidate any outstanding borrowed pointers). * * @param pq Queue to grow. * @param n Target minimum capacity. * * @return true on success, false on NULL queue or underlying * vector_reserve failure (e.g. OOM). */
| 650 | * @param n Target minimum capacity. |
| 651 | * |
| 652 | * @return true on success, false on NULL queue or underlying |
| 653 | * vector_reserve failure (e.g. OOM). |
| 654 | */ |
| 655 | bool priority_queue_reserve(PriorityQueue* pq, size_t n) { |
| 656 | PQUEUE_LOG("[priority_queue_reserve]: enter pq=%p n=%zu", (void*)pq, n); |
| 657 | |
| 658 | if (!pq || !pq->vec) { |
| 659 | PQUEUE_LOG("[priority_queue_reserve]: NULL receiver -> false"); |
| 660 | return false; |
| 661 | } |
| 662 | if (!vector_reserve(pq->vec, n)) { |
| 663 | PQUEUE_LOG("[priority_queue_reserve]: vector_reserve(%zu) failed -> false", n); |
| 664 | return false; |
| 665 | } |
| 666 | |
| 667 | PQUEUE_LOG("[priority_queue_reserve]: exit ok (capacity = %zu)", vector_capacity(pq->vec)); |
| 668 | return true; |
| 669 | } |
nothing calls this directly
no test coverage detected