# HG changeset patch # User Daniel Atallah # Date 1210558691 0 # Node ID 9004da91edd3f00cd8125027aba9aae41ccbad5a # Parent da022013ec2a04a91cf6e9128a4b1e81860e4537 Reuse cleanup function. diff -r da022013ec2a -r 9004da91edd3 libpurple/protocols/jabber/si.c --- a/libpurple/protocols/jabber/si.c Mon May 12 02:17:00 2008 +0000 +++ b/libpurple/protocols/jabber/si.c Mon May 12 02:18:11 2008 +0000 @@ -84,6 +84,21 @@ return NULL; } +static void +jabber_si_free_streamhost(gpointer data, gpointer user_data) +{ + JabberBytestreamsStreamhost *sh = data; + + if(!data) + return; + + g_free(sh->jid); + g_free(sh->host); + g_free(sh->zeroconf); + g_free(sh); +} + + static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer); @@ -110,10 +125,7 @@ streamhost->jid, streamhost->host, error_message ? error_message : "(null)"); jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost); - g_free(streamhost->jid); - g_free(streamhost->host); - g_free(streamhost->zeroconf); - g_free(streamhost); + jabber_si_free_streamhost(streamhost, NULL); jabber_si_bytestreams_attempt_connect(xfer); return; } @@ -245,10 +257,7 @@ if (jsx->connect_data == NULL) { jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost); - g_free(streamhost->jid); - g_free(streamhost->host); - g_free(streamhost->zeroconf); - g_free(streamhost); + jabber_si_free_streamhost(streamhost, NULL); jabber_si_bytestreams_attempt_connect(xfer); } } @@ -299,6 +308,7 @@ sh->host = g_strdup(host); sh->port = portnum; sh->zeroconf = g_strdup(zeroconf); + /* If there were a lot of these, it'd be worthwhile to prepend and reverse. */ jsx->streamhosts = g_list_append(jsx->streamhosts, sh); } } @@ -593,21 +603,6 @@ return strcmp(sh->jid, (char *)b); } - -static void -jabber_si_free_streamhost(gpointer data, gpointer user_data) -{ - JabberBytestreamsStreamhost *sh = data; - - if(!data) - return; - - g_free(sh->jid); - g_free(sh->host); - g_free(sh->zeroconf); - g_free(sh); -} - static void jabber_si_xfer_bytestreams_send_connected_cb(gpointer data, gint source, PurpleInputCondition cond) @@ -826,7 +821,7 @@ sh2 = g_new0(JabberBytestreamsStreamhost, 1); sh2->jid = g_strdup(sh->jid); sh2->host = g_strdup(sh->host); - sh2->zeroconf = g_strdup(sh->zeroconf); + /*sh2->zeroconf = g_strdup(sh->zeroconf);*/ sh2->port = sh->port; jsx->streamhosts = g_list_prepend(jsx->streamhosts, sh2);