changeset 28721:b8d68532c188

merge of '1db1fa363515af9bf20cd293f7ff7995d16099bb' and '3295ae2bdb4e5cae80dc9a5cdd9c53e307d5a255'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 10 Oct 2009 00:56:35 +0000
parents cb4853d04b92 (current diff) 6a23d7f84143 (diff)
children 13a229a062c6 7f80b0fc825d
files
diffstat 4 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/notification.c	Fri Oct 09 18:54:35 2009 +0000
+++ b/libpurple/protocols/msn/notification.c	Sat Oct 10 00:56:35 2009 +0000
@@ -582,7 +582,8 @@
 
 	trans = msn_transaction_new(cmdproc, "FQY", "%d", payload_len);
 	msn_transaction_set_payload(trans, payload, payload_len);
-	msn_transaction_set_data(trans, data);	/* XXX: 'data' leaks */
+	msn_transaction_set_data(trans, data);
+	msn_transaction_set_data_free(trans, g_free);
 	msn_cmdproc_send_trans(cmdproc, trans);
 }
 
@@ -962,9 +963,8 @@
 			if (cmd->trans->data) {
 				MsnFqyCbData *fqy_data = cmd->trans->data;
 				fqy_data->cb(session, passport, network, fqy_data->data);
-				/* TODO: This leaks, but the server responds to FQY multiple times, so we
-				         can't free it yet. We need to figure out somewhere else to do so.
-				g_free(fqy_data); */
+				/* Don't free fqy_data yet since the server responds to FQY multipe times.
+				   It will be freed when cmd->trans is freed. */
 			}
 
 			g_free(passport);
--- a/libpurple/protocols/msn/oim.c	Fri Oct 09 18:54:35 2009 +0000
+++ b/libpurple/protocols/msn/oim.c	Sat Oct 10 00:56:35 2009 +0000
@@ -373,6 +373,7 @@
 								msg->oim_msg);
 							g_queue_push_head(oim->send_queue, msg);
 							msn_oim_send_msg(oim);
+							msg = NULL;
 						} else {
 							purple_debug_info("msn",
 								"Can't find lock key for OIM: %s\n",
@@ -393,6 +394,7 @@
 						purple_debug_info("msn", "Resending OIM: %s\n", msg->oim_msg);
 						g_queue_push_head(oim->send_queue, msg);
 						msn_oim_send_msg(oim);
+						msg = NULL;
 					}
 				} else {
 					/* Report the error */
@@ -426,6 +428,9 @@
 			}
 		}
 	}
+
+	if (msg)
+		msn_oim_free_send_req(msg);
 }
 
 void
@@ -481,7 +486,6 @@
 
 	g_free(msg_body);
 	g_free(soap_body);
-	msn_oim_free_send_req(oim_request);
 }
 
 /****************************************
--- a/libpurple/protocols/msn/transaction.c	Fri Oct 09 18:54:35 2009 +0000
+++ b/libpurple/protocols/msn/transaction.c	Sat Oct 10 00:56:35 2009 +0000
@@ -59,6 +59,9 @@
 	g_free(trans->params);
 	g_free(trans->payload);
 
+	if (trans->data_free)
+		trans->data_free(trans->data);
+
 #if 0
 	if (trans->pendent_cmd != NULL)
 		msn_message_unref(trans->pendent_msg);
@@ -165,6 +168,12 @@
 	trans->data = data;
 }
 
+void msn_transaction_set_data_free(MsnTransaction *trans, GDestroyNotify fn)
+{
+	g_return_if_fail(trans != NULL);
+	trans->data_free = fn;
+}
+
 void
 msn_transaction_add_cb(MsnTransaction *trans, char *answer,
 					   MsnTransCb cb)
--- a/libpurple/protocols/msn/transaction.h	Fri Oct 09 18:54:35 2009 +0000
+++ b/libpurple/protocols/msn/transaction.h	Sat Oct 10 00:56:35 2009 +0000
@@ -48,6 +48,8 @@
 	guint timer;
 
 	void *data; /**< The data to be used on the different callbacks. */
+	GDestroyNotify data_free;  /**< The function to free 'data', or @c NULL */
+
 	GHashTable *callbacks;
 	gboolean has_custom_callbacks;
 	MsnErrorCb error_cb;
@@ -71,6 +73,7 @@
 void msn_transaction_set_payload(MsnTransaction *trans,
 								 const char *payload, int payload_len);
 void msn_transaction_set_data(MsnTransaction *trans, void *data);
+void msn_transaction_set_data_free(MsnTransaction *trans, GDestroyNotify fn);
 void msn_transaction_add_cb(MsnTransaction *trans, char *answer,
 							MsnTransCb cb);
 void msn_transaction_set_error_cb(MsnTransaction *trans, MsnErrorCb cb);