pidgin: 38a143a9: When adding outgoing MSN commands to the...

markdoliner at pidgin.im markdoliner at pidgin.im
Tue May 20 17:05:50 EDT 2008


-----------------------------------------------------------------
Revision: 38a143a948abbbfeb8fc6623161a3dc177469484
Ancestor: 0130292e82764988f2d833f4a5d3ff5523f2eb7f
Author: markdoliner at pidgin.im
Date: 2008-05-20T20:59:21
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/38a143a948abbbfeb8fc6623161a3dc177469484

Modified files:
        libpurple/protocols/msn/cmdproc.c
        libpurple/protocols/msn/msg.c
        libpurple/protocols/msnp9/cmdproc.c
        libpurple/protocols/msnp9/msg.c

ChangeLog: 

When adding outgoing MSN commands to the MsnHistory, free
MsnTransaction->payload to save memory.

MSN_HIST_ELEMS * MSN_BUF_LEN (used in msn_message_gen_payload)
 = 48 * 8192 bytes = 384 KB per online MSN account = a lot of wasted memory

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/cmdproc.c	7aab4f5e89e84422a0f0185b942170e64caf2d8b
+++ libpurple/protocols/msn/cmdproc.c	e3d66bb017e97382b6b24b2ef4cbb8a1eb6db158
@@ -132,6 +132,14 @@ msn_cmdproc_send_trans(MsnCmdProc *cmdpr
 		data = g_realloc(data, len + trans->payload_len);
 		memcpy(data + len, trans->payload, trans->payload_len);
 		len += trans->payload_len;
+
+		/*
+		 * We're done with trans->payload.  Free it so that the memory
+		 * doesn't sit around in cmdproc->history.
+		 */
+		g_free(trans->payload);
+		trans->payload = NULL;
+		trans->payload_len = 0;
 	}
 
 	msn_servconn_write(servconn, data, len);
============================================================
--- libpurple/protocols/msn/msg.c	91cab16e2f23c0fd8832a52d41a3c5bc4ad613dc
+++ libpurple/protocols/msn/msg.c	ee4fe6710de12cdec6963878f04b6c69af81b16c
@@ -151,6 +151,7 @@ msn_message_new_nudge(void)
 	MsnMessage *msg;
 
 	msg = msn_message_new(MSN_MSG_NUDGE);
+	/* TODO: This shouldn't have a \r\n in it, should it?? */
 	msn_message_set_content_type(msg, "text/x-msnmsgr-datacast\r\n");
 	msn_message_set_flag(msg, 'N');
 	msn_message_set_attr(msg,"ID","1\r\n");
============================================================
--- libpurple/protocols/msnp9/cmdproc.c	800a37bba57fe06cbb24458eb0f3cc4ff5291af0
+++ libpurple/protocols/msnp9/cmdproc.c	da57c6bf5bfa6224cdc0e9e97d80e6627093e346
@@ -132,6 +132,14 @@ msn_cmdproc_send_trans(MsnCmdProc *cmdpr
 		data = g_realloc(data, len + trans->payload_len);
 		memcpy(data + len, trans->payload, trans->payload_len);
 		len += trans->payload_len;
+
+		/*
+		 * We're done with trans->payload.  Free it so that the memory
+		 * doesn't sit around in cmdproc->history.
+		 */
+		g_free(trans->payload);
+		trans->payload = NULL;
+		trans->payload_len = 0;
 	}
 
 	msn_servconn_write(servconn, data, len);
============================================================
--- libpurple/protocols/msnp9/msg.c	df21cf628802ad67fb9a8759fb3a188c56d391fa
+++ libpurple/protocols/msnp9/msg.c	440386f3df72373a70d473ec4ffc289ca2526db5
@@ -158,6 +158,7 @@ msn_message_new_nudge(void)
 	MsnMessage *msg;
 
 	msg = msn_message_new(MSN_MSG_NUDGE);
+	/* TODO: This shouldn't have a \r\n in it, should it?? */
 	msn_message_set_content_type(msg, "text/x-msnmsgr-datacast\r\n");
 	msn_message_set_flag(msg, 'N');
 	msn_message_set_attr(msg,"ID","1\r\n");


More information about the Commits mailing list