MXit: Rather use g_memdup() here than allocating a buffer and copying the data ourselves. release-2.x.y

Wed, 16 Jan 2013 11:18:50 +0200

author
Andrew Victor <andrew.victor@mxit.com>
date
Wed, 16 Jan 2013 11:18:50 +0200
branch
release-2.x.y
changeset 33615
658b4037b8f6
parent 33614
03bb2e5cb1d0
child 33616
18f065e935eb

MXit: Rather use g_memdup() here than allocating a buffer and copying the data ourselves.

libpurple/protocols/mxit/formcmds.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/mxit/formcmds.c	Wed Jan 16 11:03:44 2013 +0200
+++ b/libpurple/protocols/mxit/formcmds.c	Wed Jan 16 11:18:50 2013 +0200
@@ -86,7 +86,6 @@
 static void mxit_cb_ii_returned(PurpleUtilFetchUrlData* url_data, gpointer user_data, const gchar* url_text, gsize len, const gchar* error_message)
 {
 	struct ii_url_request*	iireq		= (struct ii_url_request*) user_data;
-	char*					ii_data;
 	int*					intptr		= NULL;
 	int						id;
 
@@ -106,12 +105,8 @@
 		goto done;
 	}
 
-	/* make a copy of the data */
-	ii_data = g_malloc(len);
-	memcpy(ii_data, (const char*) url_text, len);
-
-	/* we now have the inline image, store it in the imagestore */
-	id = purple_imgstore_add_with_id(ii_data, len, NULL);
+	/* we now have the inline image, store a copy in the imagestore */
+	id = purple_imgstore_add_with_id(g_memdup(url_text, len), len, NULL);
 
 	/* map the inline image id to purple image id */
 	intptr = g_malloc(sizeof(int));

mercurial