pidgin.vv.msn.webcam: fd0ebaab: Reduce some memdups.

qulogic at pidgin.im qulogic at pidgin.im
Fri Sep 3 03:37:05 EDT 2010


----------------------------------------------------------------------
Revision: fd0ebaab4feb089b101768df831688c995530e44
Parent:   4356ac1b469717f003380c895216c130673234e3
Author:   qulogic at pidgin.im
Date:     08/30/10 03:42:04
Branch:   im.pidgin.pidgin.vv.msn.webcam
URL: http://d.pidgin.im/viewmtn/revision/info/fd0ebaab4feb089b101768df831688c995530e44

Changelog: 

Reduce some memdups.

Changes against parent 4356ac1b469717f003380c895216c130673234e3

  patched  libpurple/protocols/msn/webcam.c

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/webcam.c	b464abac71aa16a3be0c95bc6d3880d743554df8
+++ libpurple/protocols/msn/webcam.c	040baefca0f3a70084f08ad14288fb1ff8766520
@@ -229,23 +229,23 @@ msn_webcam_send_syn(MsnSlpCall *slpcall,
 	msn_slplink_queue_slpmsg(slpcall->slplink, slpmsg);
 }
 
+#define WEBCAM_ACK \
+	"\x80" \
+	"\xea\00" \
+	"\x00" \
+	"\x08\x00" \
+	"\x08\x00\x00\x00" \
+	"a\0c\x00k\x00\x00\x00"
+
 void
 msn_webcam_send_ack(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
 {
 	MsnSlpMessage *slpmsg2;
-	MsnWebcamData *body = g_memdup("\x80"
-	                               "\xea\00"
-	                               "\x00"
-	                               "\x08\x00"
-	                               "\x08\x00\x00\x00"
-	                               "a\0c\x00k\x00\x00\x00",
-	                               18);
 
 	slpmsg2 = msn_slpmsg_new(slplink);
 	slpmsg2->slpcall = slpmsg->slpcall;
 	slpmsg2->session_id = slpmsg->session_id;
-	msn_slpmsg_set_body(slpmsg2, (char *)body, 18);
-	g_free(body);
+	msn_slpmsg_set_body(slpmsg2, WEBCAM_ACK, sizeof(WEBCAM_ACK) - 1);
 	msn_slplink_queue_slpmsg(slplink, slpmsg2);
 	purple_media_stream_info(slpmsg->slpcall->media,
 			PURPLE_MEDIA_INFO_ACCEPT, "msncam-send",
@@ -373,7 +373,6 @@ msn_webcam_recv_xml(MsnSlpLink *slplink,
 	MsnWebcamData *request = (MsnWebcamData *)body;
 	gsize bytes_written;
 	gchar *xml;
-	MsnWebcamData *reply;
 	gboolean is_producer = FALSE;
 
 	xml = g_convert((const gchar *)request->data, body_len - sizeof(MsnWebcamData),
@@ -461,22 +460,21 @@ msn_webcam_recv_xml(MsnSlpLink *slplink,
 		purple_media_add_remote_candidates(slpmsg->slpcall->media,
 				"msncam-recv", slplink->remote_user, candidates);
 	} else {
+#define WEBCAM_RECEIVER_REPLY \
+		/* magic string */ \
+		"\x80" \
+		"\xec\x00" \
+		"\x03" \
+		"\x08\x00" \
+		/* length of following */ \
+		"\x16\x00\x00\x00" \
+		/* actual data */ \
+		"r\0e\0c\0e\0i\0v\0e\0d\0V\0i\0e\0w\0e\0r\0D\0a\0t\0a\0\0\0"
+
 		slpmsg2 = msn_slpmsg_new(slplink);
 		slpmsg2->slpcall = slpmsg->slpcall;
 		slpmsg2->session_id = slpmsg->session_id;
-		reply = (MsnWebcamData *)g_memdup(
-				/* magic string */
-				"\x80"
-				"\xec\x00"
-				"\x03"
-				"\x08\x00"
-				/* length of following */
-				"\x16\x00\x00\x00"
-				/* actual data */
-				"r\0e\0c\0e\0i\0v\0e\0d\0V\0i\0e\0w\0e\0r\0D\0a\0t\0a\0\0\0",
-				48);
-		msn_slpmsg_set_body(slpmsg2, (char *)reply, 48);
-		g_free(reply);
+		msn_slpmsg_set_body(slpmsg2, WEBCAM_RECEIVER_REPLY, sizeof(WEBCAM_RECEIVER_REPLY) - 1);
 		msn_slplink_queue_slpmsg(slplink, slpmsg2);
 	}
 	g_free(xml);


More information about the Commits mailing list