Simplify some malloc+printfs to g_strdup_printf.

Wed, 02 Oct 2019 03:36:46 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Wed, 02 Oct 2019 03:36:46 -0400
changeset 39911
3c0d4b834fea
parent 39910
68b48a2152f8
child 39912
94c809048a88

Simplify some malloc+printfs to g_strdup_printf.

libpurple/protocols/oscar/family_locate.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/oscar/family_locate.c	Wed Oct 02 03:27:00 2019 -0400
+++ b/libpurple/protocols/oscar/family_locate.c	Wed Oct 02 03:36:46 2019 -0400
@@ -1291,9 +1291,7 @@
 
 	/* Build the packet first to get real length */
 	if (profile) {
-		/* no + 1 here because of %s */
-		encoding = g_malloc(strlen(defencoding) + strlen(profile_encoding));
-		snprintf(encoding, strlen(defencoding) + strlen(profile_encoding), defencoding, profile_encoding);
+		encoding = g_strdup_printf(defencoding, profile_encoding);
 		aim_tlvlist_add_str(&tlvlist, 0x0001, encoding);
 		aim_tlvlist_add_raw(&tlvlist, 0x0002, profile_len, (const guchar *)profile);
 		g_free(encoding);
@@ -1309,8 +1307,7 @@
 	 */
 	if (awaymsg) {
 		if (awaymsg_len) {
-			encoding = g_malloc(strlen(defencoding) + strlen(awaymsg_encoding));
-			snprintf(encoding, strlen(defencoding) + strlen(awaymsg_encoding), defencoding, awaymsg_encoding);
+			encoding = g_strdup_printf(defencoding, awaymsg_encoding);
 			aim_tlvlist_add_str(&tlvlist, 0x0003, encoding);
 			aim_tlvlist_add_raw(&tlvlist, 0x0004, awaymsg_len, (const guchar *)awaymsg);
 			g_free(encoding);

mercurial