From 8979ccb48bec7a2ed82ead065a451ff4a12bdf5c Mon Sep 17 00:00:00 2001 From: Sascha Kruse Date: Mon, 12 Sep 2011 18:16:41 +0200 Subject: [PATCH] list_len(...) --- dunst.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dunst.c b/dunst.c index d5dc8ce..0d8149f 100644 --- a/dunst.c +++ b/dunst.c @@ -57,6 +57,7 @@ static int message_h; /* list functions */ msg_queue_t *append(msg_queue_t *queue, char *msg); msg_queue_t *pop(msg_queue_t *queue); +int list_len(msg_queue_t *list); /* misc funtions */ @@ -102,6 +103,18 @@ pop(msg_queue_t *queue) { return new_head; } +int list_len(msg_queue_t *list) { + int count = 0; + msg_queue_t *i; + if(list == NULL) { + return 0; + } + for(i = list; i != NULL; i = i->next) { + count++; + } + return count; +} + void drawmsg(const char *msg) { int width, x, y;