diff --git a/queue.c b/queue.c index ce85f7d16..eac0cdce6 100644 --- a/queue.c +++ b/queue.c @@ -47,7 +47,14 @@ element_t *q_remove_tail(struct list_head *head, char *sp, size_t bufsize) /* Return number of elements in queue */ int q_size(struct list_head *head) { - return -1; + if (!head) + return 0; + + int size = 0; + struct list_head *curr; + list_for_each (curr, head) + size++; + return size; } /* Delete the middle node in queue */