libpurple/protocols/jabber/adhoccommands.c

changeset 40137
016690872c6c
parent 40043
90446617d967
child 40358
e6fe6fc1f516
--- a/libpurple/protocols/jabber/adhoccommands.c	Sun Nov 03 20:33:05 2019 +0300
+++ b/libpurple/protocols/jabber/adhoccommands.c	Sun Nov 03 20:37:07 2019 +0300
@@ -58,17 +58,9 @@
 	if(!jbr)
 		return;
 
-	if(jbr->commands) {
-		/* since the list we just received is complete, wipe the old one */
-		while(jbr->commands) {
-			JabberAdHocCommands *cmd = jbr->commands->data;
-			g_free(cmd->jid);
-			g_free(cmd->node);
-			g_free(cmd->name);
-			g_free(cmd);
-			jbr->commands = g_list_delete_link(jbr->commands, jbr->commands);
-		}
-	}
+	/* since the list we just received is complete, wipe the old one */
+	g_list_free_full(jbr->commands, (GDestroyNotify)jabber_adhoc_commands_free);
+	jbr->commands = NULL;
 
 	for(item = query->child; item; item = item->next) {
 		JabberAdHocCommands *cmd;
@@ -241,14 +233,8 @@
 		return;
 
 	/* clean current list (just in case there is one) */
-	while(js->commands) {
-		JabberAdHocCommands *cmd = js->commands->data;
-		g_free(cmd->jid);
-		g_free(cmd->node);
-		g_free(cmd->name);
-		g_free(cmd);
-		js->commands = g_list_delete_link(js->commands, js->commands);
-	}
+	g_list_free_full(js->commands, (GDestroyNotify)jabber_adhoc_commands_free);
+	js->commands = NULL;
 
 	/* re-fill list */
 	for(item = query->child; item; item = item->next) {

mercurial