summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-03-30 15:19:53 +0100
committerLennart Poettering <lennart@poettering.net>2013-03-30 15:21:55 +0100
commita3de5ae1d7d881bbd4869c6c4a200c84bda00ced (patch)
treec975f4df59ef9bd968adc400850781ac95af538a /src
parent5384d4b3d76424a466fe54da744dca8711ffa60f (diff)
downloadsystemd-a3de5ae1d7d881bbd4869c6c4a200c84bda00ced.tar.gz
prioq: consider a NULL prioq empty
Diffstat (limited to 'src')
-rw-r--r--src/shared/prioq.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/shared/prioq.c b/src/shared/prioq.c
index b7d745990c..64c44aef82 100644
--- a/src/shared/prioq.c
+++ b/src/shared/prioq.c
@@ -236,7 +236,8 @@ static struct prioq_item* find_item(Prioq *q, void *data, unsigned *idx) {
int prioq_remove(Prioq *q, void *data, unsigned *idx) {
struct prioq_item *i;
- assert(q);
+ if (!q)
+ return 0;
i = find_item(q, data, idx);
if (!i)
@@ -263,7 +264,9 @@ int prioq_reshuffle(Prioq *q, void *data, unsigned *idx) {
}
void *prioq_peek(Prioq *q) {
- assert(q);
+
+ if (!q)
+ return NULL;
if (q->n_items <= 0)
return NULL;
@@ -274,7 +277,8 @@ void *prioq_peek(Prioq *q) {
void *prioq_pop(Prioq *q) {
void *data;
- assert(q);
+ if (!q)
+ return NULL;
if (q->n_items <= 0)
return NULL;
@@ -285,13 +289,17 @@ void *prioq_pop(Prioq *q) {
}
unsigned prioq_size(Prioq *q) {
- assert(q);
+
+ if (!q)
+ return 0;
return q->n_items;
}
bool prioq_isempty(Prioq *q) {
- assert(q);
+
+ if (!q)
+ return true;
return q->n_items <= 0;
}