return q;
}
-void prioq_free(Prioq *q) {
+Prioq* prioq_free(Prioq *q) {
if (!q)
- return;
+ return NULL;
free(q->items);
free(q);
+
+ return NULL;
}
int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func) {
assert(q);
if (idx) {
- if (*idx > q->n_items)
+ if (*idx == PRIOQ_IDX_NULL ||
+ *idx > q->n_items)
return NULL;
i = q->items + *idx;
return 0;
return q->n_items;
-
}
+
bool prioq_isempty(Prioq *q) {
if (!q)