X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fprioq.c;h=b89888be0e8d5460313ffc3e9712856f214ce5d2;hb=ce5792dac67c5ae5656f1f9665b777d44af4cb35;hp=2d166360aa213c5fc4e170506992f2ac93539a8b;hpb=44a6b1b68029833893f6e9cee35aa27a974038f6;p=elogind.git diff --git a/src/shared/prioq.c b/src/shared/prioq.c index 2d166360a..b89888be0 100644 --- a/src/shared/prioq.c +++ b/src/shared/prioq.c @@ -45,12 +45,14 @@ Prioq *prioq_new(compare_func_t compare_func) { 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) { @@ -217,7 +219,8 @@ _pure_ static struct prioq_item* find_item(Prioq *q, void *data, unsigned *idx) assert(q); if (idx) { - if (*idx > q->n_items) + if (*idx == PRIOQ_IDX_NULL || + *idx > q->n_items) return NULL; i = q->items + *idx; @@ -294,8 +297,8 @@ unsigned prioq_size(Prioq *q) { return 0; return q->n_items; - } + bool prioq_isempty(Prioq *q) { if (!q)