changeset 14039:5e6d4c36630a

[gaim-migrate @ 16643] Return g_string_free(str, FALSE) directly instead of assigning str->str to a temporary directory and returning that. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 05 Aug 2006 09:17:09 +0000
parents 443aaa05a7c3
children 80891029f5dd
files src/gtkimhtml.c src/util.c
diffstat 2 files changed, 36 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkimhtml.c	Sat Aug 05 09:11:46 2006 +0000
+++ b/src/gtkimhtml.c	Sat Aug 05 09:17:09 2006 +0000
@@ -220,7 +220,6 @@
 	int length;
 	GString *clipboard;
 	gchar *tmp;
-	gchar *ret;
 
 	if (html == NULL)
 		return NULL;
@@ -238,14 +237,8 @@
 	g_string_append(clipboard, "<!--StartFragment-->\r\n");
 	g_string_append(clipboard, html);
 	g_string_append(clipboard, "\r\n<!--EndFragment-->");
-	ret = clipboard->str;
-	g_string_free(clipboard, FALSE);
-
-#if 0 /* Debugging for Windows clipboard */
-	gaim_debug_info("imhtml clipboard", "from gaim: %s\n", ret);
-#endif
-
-	return ret;
+
+	return g_string_free(clipboard, FALSE);
 }
 
 static void clipboard_copy_html_win32(GtkIMHtml *imhtml) {
@@ -2229,11 +2222,9 @@
 			e++;
 		}
 	}
-
 	g_free(val);
-	val = ret->str;
-	g_string_free(ret, FALSE);
-	return val;
+
+	return g_string_free(ret, FALSE);
 }
 
 static const char *accepted_protocols[] = {
--- a/src/util.c	Sat Aug 05 09:11:46 2006 +0000
+++ b/src/util.c	Sat Aug 05 09:17:09 2006 +0000
@@ -2026,40 +2026,40 @@
 
 char *
 gaim_unescape_html(const char *html) {
-	char *unescaped = NULL;
-
-	if (html != NULL) {
-		const char *c = html;
-		GString *ret = g_string_new("");
-		while (*c) {
-			if (!strncmp(c, "&amp;", 5)) {
-				ret = g_string_append_c(ret, '&');
-				c += 5;
-			} else if (!strncmp(c, "&lt;", 4)) {
-				ret = g_string_append_c(ret, '<');
-				c += 4;
-			} else if (!strncmp(c, "&gt;", 4)) {
-				ret = g_string_append_c(ret, '>');
-				c += 4;
-			} else if (!strncmp(c, "&quot;", 6)) {
-				ret = g_string_append_c(ret, '"');
-				c += 6;
-			} else if (!strncmp(c, "&apos;", 6)) {
-				ret = g_string_append_c(ret, '\'');
-				c += 6;
-			} else if (!strncmp(c, "<br>", 4)) {
-				ret = g_string_append_c(ret, '\n');
-				c += 4;
-			} else {
-				ret = g_string_append_c(ret, *c);
-				c++;
-			}
+	const char *c;
+	GString *ret;
+
+	if (html == NULL)
+		return NULL;
+
+	c = html;
+	ret = g_string_new("");
+	while (*c) {
+		if (!strncmp(c, "&amp;", 5)) {
+			ret = g_string_append_c(ret, '&');
+			c += 5;
+		} else if (!strncmp(c, "&lt;", 4)) {
+			ret = g_string_append_c(ret, '<');
+			c += 4;
+		} else if (!strncmp(c, "&gt;", 4)) {
+			ret = g_string_append_c(ret, '>');
+			c += 4;
+		} else if (!strncmp(c, "&quot;", 6)) {
+			ret = g_string_append_c(ret, '"');
+			c += 6;
+		} else if (!strncmp(c, "&apos;", 6)) {
+			ret = g_string_append_c(ret, '\'');
+			c += 6;
+		} else if (!strncmp(c, "<br>", 4)) {
+			ret = g_string_append_c(ret, '\n');
+			c += 4;
+		} else {
+			ret = g_string_append_c(ret, *c);
+			c++;
 		}
-
-		unescaped = ret->str;
-		g_string_free(ret, FALSE);
 	}
-	return unescaped;
+
+	return g_string_free(ret, FALSE);
 
 }