fixed wrong deletion order of messages

and gave the variable 'tmp' a better name
This commit is contained in:
Sascha Kruse 2011-09-17 18:59:29 +02:00
parent 6cec7aa72d
commit ba6c00bad1

10
dunst.c
View File

@ -197,20 +197,20 @@ check_timeouts(void) {
void void
delete_msg(msg_queue_t *elem) { delete_msg(msg_queue_t *elem) {
msg_queue_t *cur; msg_queue_t *cur;
msg_queue_t *tmp; msg_queue_t *min;
int visible_count = 0; int visible_count = 0;
if(msgqueue == NULL) { if(msgqueue == NULL) {
return; return;
} }
if(elem == NULL) { if(elem == NULL) {
/* delete the oldest element */ /* delete the oldest element */
tmp = msgqueue; min = msgqueue;
for(elem = msgqueue; elem->next != NULL; elem = elem->next) { for(elem = msgqueue; elem->next != NULL; elem = elem->next) {
if(tmp->start > 0 && tmp->start > elem->start) { if(elem->start > 0 && min->start > elem->start) {
tmp = elem; min = elem;
} }
} }
elem = tmp; elem = min;
} }
msgqueue = delete(elem); msgqueue = delete(elem);
for(cur = msgqueue; cur != NULL; cur = cur->next) { for(cur = msgqueue; cur != NULL; cur = cur->next) {