Cleaned up lm_connection_unref_message_handler.
authorMikael Hallendal <micke@imendio.com>
Wed, 21 Feb 2007 13:24:28 +0100
changeset 207 6dd9dc2f6b69
parent 206 422369c66071
child 208 79974b436e7d
Cleaned up lm_connection_unref_message_handler. Use g_slist_remove_link instead of own hack to remove a link from the list.
loudmouth/lm-connection.c
--- a/loudmouth/lm-connection.c	Mon Feb 12 16:49:49 2007 +0100
+++ b/loudmouth/lm-connection.c	Wed Feb 21 13:24:28 2007 +0100
@@ -1577,7 +1577,7 @@
 					  LmMessageHandler  *handler,
 					  LmMessageType      type)
 {
-	GSList *l, *prev = NULL;
+	GSList *l;
 	
 	g_return_if_fail (connection != NULL);
 	g_return_if_fail (handler != NULL);
@@ -1586,19 +1586,13 @@
 	for (l = connection->handlers[type]; l; l = l->next) {
 		HandlerData *hd = (HandlerData *) l->data;
 		
-		if (hd->handler == handler) {
-			if (prev) {
-				prev->next = l->next;
-			} else {
-				connection->handlers[type] = l->next;
-			}
-			l->next = NULL;
+		if (handler == hd->handler) {
+			connection->handlers[type] = g_slist_remove_link (connection->handlers[type], l);
 			g_slist_free (l);
 			lm_message_handler_unref (hd->handler);
 			g_free (hd);
 			break;
 		}
-		prev = l;
 	}
 }