changeset 22134:33abfb98a460

Since I needed to bring back yahoo_convert_to_numeric, I figured I could at least clean it up a little bit. Refs #3295.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Thu, 17 Jan 2008 06:11:57 +0000
parents 0d7d0a60d42d
children 3550c5d7c493
files libpurple/protocols/yahoo/util.c
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/util.c	Thu Jan 17 05:53:25 2008 +0000
+++ b/libpurple/protocols/yahoo/util.c	Thu Jan 17 06:11:57 2008 +0000
@@ -166,15 +166,20 @@
 
 char *yahoo_convert_to_numeric(const char *str)
 {
-	char *retstr, buf[7];
+	GString *gstr = NULL;
+	char *retstr;
 	const char *p;
 
-	retstr = (char*)malloc(strlen(str) * 6 + 1);
-	memset(retstr, 0x00, sizeof(retstr));
+	gstr = g_string_sized_new(strlen(str) * 6 + 1);
+
 	for (p = str; *p; p++) {
-		sprintf(buf, "&#%d;", (unsigned char)*p);
-		strcat(retstr, buf);
+		g_string_append_printf(gstr, "&#%u;", *p);
 	}
+
+	retstr = gstr->str;
+
+	g_string_free(gstr, FALSE);
+
 	return retstr;
 }