[ekg2-commit] ekg2: msgqueue.c (HEAD) [darkjames]

CVS commit cvs w toxygen.net
Czw, 22 Lis 2007, 22:55:13 CET


Module name:	ekg2
Changes by:	darkjames	2007-11-22 22:55:11

Modified files:
	msgqueue.c

Index: msgqueue.c
===================================================================
RCS file: /home/cvs/ekg2/ekg/msgqueue.c,v
diff -d -u -r1.26 -r1.27
--- msgqueue.c	28 May 2007 23:27:04 -0000	1.26
+++ msgqueue.c	22 Nov 2007 21:55:11 -0000	1.27
@@ -65,23 +65,12 @@
 	return (list_add(&msg_queue, m, 0) ? 0 : -1);
 }
 
-/*
- * msg_queue_remove()
- *
- * usuwa wiadomość o podanym numerze sekwencyjnym z kolejki wiadomości.
- *
- *  - msg - struktura opisująca wiadomość.
- *
- * 0 jeśli usunięto, -1 jeśli nie ma takiej wiadomości.
- */
-static void msg_queue_remove(msg_queue_t *m)
-{
-	xfree(m->session);
-	xfree(m->rcpts);
-	xfree(m->message);
-	xfree(m->seq);
-
-	list_remove(&msg_queue, m, 1);
+static LIST_FREE_ITEM(list_msg_queue_free, msg_queue_t *) {
+	xfree(data->session);
+	xfree(data->rcpts);
+	xfree(data->message);
+	xfree(data->seq);
+	xfree(data);
 }
 
 /*
@@ -105,7 +94,7 @@
 		l = l->next;
 
 		if (!xstrcasecmp(m->rcpts, uid)) {
-			msg_queue_remove(m);
+			LIST_REMOVE(&msg_queue, m, list_msg_queue_free);
 			res = 0;
 		}
 	}
@@ -136,7 +125,7 @@
 		l = l->next;
 
 		if (!xstrcasecmp(m->seq, seq)) {
-			msg_queue_remove(m);
+			LIST_REMOVE(&msg_queue, m, list_msg_queue_free);
 			res = 0;
 		}
 	}
@@ -149,19 +138,8 @@
  *
  * zwalnia pamięć po kolejce wiadomości.
  */
-void msg_queue_free()
-{
-	list_t l;
-
-	for (l = msg_queue; l; ) {
-		msg_queue_t *m = l->data;
-
-		l = l->next;
-
-		msg_queue_remove(m);
-	}
-
-	list_destroy(msg_queue, 1);
+void msg_queue_free() {
+	LIST_DESTROY(msg_queue, list_msg_queue_free);
 	msg_queue = NULL;
 }
 
@@ -199,7 +177,7 @@
 
 		/* wiadomość wysyłana z nieistniejącej już sesji? usuwamy. */
 		if (!(s = session_find(m->session))) {
-			msg_queue_remove(m);
+			LIST_REMOVE(&msg_queue, m, list_msg_queue_free);
 			continue;
 		}
 
@@ -208,7 +186,7 @@
 
 		command_exec_format(NULL, s, 1, ("/msg \"%s\" %s"), m->rcpts, m->message);
 
-		msg_queue_remove(m);
+		LIST_REMOVE(&msg_queue, m, list_msg_queue_free);
 
 		sent = 1;
 	}


Więcej informacji o liście dyskusyjnej ekg2-commit