MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / queue_capacity

Function queue_capacity

queue/queue.c:239–250  ·  view source on GitHub ↗

* @brief Allocated capacity of the underlying vector. * * Capacity ≥ size; the queue can absorb (capacity - size) more * pushes without re-allocating. * * @param q Queue pointer. NULL returns 0. * @return Capacity in elements. */

Source from the content-addressed store, hash-verified

237
238 size_t n = src->vec->size - src->frontIndex;
239 if (n > 0 && !vector_reserve(dest->vec, n)) {
240 QUEUE_LOG("[queue_assign]: reserve(%zu) failed -> false", n);
241 return false;
242 }
243 for (size_t i = 0; i < n; ++i) {
244 void* elem = vector_at(src->vec, src->frontIndex + i);
245 if (!elem || !vector_push_back(dest->vec, elem)) {
246 QUEUE_LOG("[queue_assign]: push_back failed at index %zu -> false", i);
247 return false;
248 }
249 }
250 QUEUE_LOG("[queue_assign]: exit ok (%zu elements assigned)", n);
251 return true;
252}
253

Callers

nothing calls this directly

Calls 1

vector_capacityFunction · 0.85

Tested by

no test coverage detected