Use g_string_free_and_steal

Thu, 02 Jan 2025 22:37:44 -0600

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Thu, 02 Jan 2025 22:37:44 -0600
changeset 43123
4d3b58b6cf06
parent 43122
1f63e7d9d689
child 43124
711b58ead6df

Use g_string_free_and_steal

Added in 2.76, and we require 2.78 now. Also, remove an outdated comment about it.

Testing Done:
Compiled and ran `ninja turtles`.

Reviewed at https://reviews.imfreedom.org/r/3722/

libpurple/prefs.c file | annotate | diff | comparison | revisions
libpurple/purplemarkup.c file | annotate | diff | comparison | revisions
libpurple/purpletags.c file | annotate | diff | comparison | revisions
libpurple/xmlnode.c file | annotate | diff | comparison | revisions
meson.build file | annotate | diff | comparison | revisions
pidgin/pidginabout.c file | annotate | diff | comparison | revisions
pidgin/pidgincontactlist.c file | annotate | diff | comparison | revisions
--- a/libpurple/prefs.c	Wed Jan 01 15:40:13 2025 -0600
+++ b/libpurple/prefs.c	Thu Jan 02 22:37:44 2025 -0600
@@ -521,7 +521,7 @@
 		name = g_string_prepend(name, parent->name);
 	}
 	name = g_string_prepend_c(name, '/');
-	return g_string_free(name, FALSE);
+	return g_string_free_and_steal(name);
 }
 
 static struct purple_pref *
--- a/libpurple/purplemarkup.c	Wed Jan 01 15:40:13 2025 -0600
+++ b/libpurple/purplemarkup.c	Thu Jan 02 22:37:44 2025 -0600
@@ -625,9 +625,9 @@
 	}
 	g_clear_list(&tags, g_free);
 	if(xhtml_out)
-		*xhtml_out = g_string_free(xhtml, FALSE);
+		*xhtml_out = g_string_free_and_steal(xhtml);
 	if(plain_out)
-		*plain_out = g_string_free(plain, FALSE);
+		*plain_out = g_string_free_and_steal(plain);
 	if(url)
 		g_string_free(url, TRUE);
 	if (cdata)
@@ -1024,7 +1024,7 @@
 				if (badchar(*t) || (g >= 127) || (*t == ')') || badentity(t)) {
 					char *d;
 
-					url_buf = g_string_free(gurl_buf, FALSE);
+					url_buf = g_string_free_and_steal(gurl_buf);
 					gurl_buf = NULL;
 
 					/* strip off trailing periods */
@@ -1069,7 +1069,7 @@
 		c++;
 
 	}
-	return g_string_free(ret, FALSE);
+	return g_string_free_and_steal(ret);
 }
 
 char *purple_unescape_text(const char *in)
@@ -1094,7 +1094,7 @@
         }
     }
 
-    return g_string_free(ret, FALSE);
+    return g_string_free_and_steal(ret);
 }
 
 char *purple_unescape_html(const char *html)
@@ -1122,7 +1122,7 @@
 		}
 	}
 
-	return g_string_free(ret, FALSE);
+	return g_string_free_and_steal(ret);
 }
 
 char *
@@ -1231,7 +1231,7 @@
 	}
 
 	g_queue_free(q);
-	return g_string_free(ret, FALSE);
+	return g_string_free_and_steal(ret);
 }
 
 char *
--- a/libpurple/purpletags.c	Wed Jan 01 15:40:13 2025 -0600
+++ b/libpurple/purpletags.c	Thu Jan 02 22:37:44 2025 -0600
@@ -372,7 +372,7 @@
 		}
 	}
 
-	return g_string_free(value, FALSE);
+	return g_string_free_and_steal(value);
 }
 
 void
--- a/libpurple/xmlnode.c	Wed Jan 01 15:40:13 2025 -0600
+++ b/libpurple/xmlnode.c	Thu Jan 02 22:37:44 2025 -0600
@@ -468,7 +468,7 @@
 		return NULL;
 	}
 
-	return g_string_free(str, FALSE);
+	return g_string_free_and_steal(str);
 }
 
 char *
@@ -600,7 +600,7 @@
 		*len = text->len;
 	}
 
-	return g_string_free(text, FALSE);
+	return g_string_free_and_steal(text);
 }
 
 char *
--- a/meson.build	Wed Jan 01 15:40:13 2025 -0600
+++ b/meson.build	Thu Jan 02 22:37:44 2025 -0600
@@ -171,8 +171,6 @@
 #######################################################################
 # Check for GLib (required)
 #######################################################################
-# Once we require >= 2.74.0, remove the hack in the if(TRUE) block in
-# libpurple/core.c.
 glib = dependency('glib-2.0', version : '>= 2.78.0')
 gio = dependency('gio-2.0')
 gnome = import('gnome')
--- a/pidgin/pidginabout.c	Wed Jan 01 15:40:13 2025 -0600
+++ b/pidgin/pidginabout.c	Thu Jan 02 22:37:44 2025 -0600
@@ -423,7 +423,7 @@
 	g_free(sound_theme_name);
 	g_free(theme_name);
 
-	return g_string_free(info, FALSE);
+	return g_string_free_and_steal(info);
 }
 
 static void
@@ -459,7 +459,7 @@
 		paths = paths->next;
 	}
 
-	return g_string_free(info, FALSE);
+	return g_string_free_and_steal(info);
 }
 
 static void
@@ -535,7 +535,7 @@
 		g_free(value);
 	}
 
-	return g_string_free(info, FALSE);
+	return g_string_free_and_steal(info);
 }
 
 static void
@@ -625,7 +625,7 @@
 		g_free(info);
 #endif
 
-		info = g_string_free(everything, FALSE);
+		info = g_string_free_and_steal(everything);
 	}
 
 	clipboard = gtk_widget_get_clipboard(GTK_WIDGET(about));
--- a/pidgin/pidgincontactlist.c	Wed Jan 01 15:40:13 2025 -0600
+++ b/pidgin/pidgincontactlist.c	Thu Jan 02 22:37:44 2025 -0600
@@ -278,7 +278,7 @@
 	const char *tmp = NULL;
 
 	if(!PURPLE_IS_PRESENCE(presence)) {
-		return g_string_free(str, FALSE);
+		return g_string_free_and_steal(str);
 	}
 
 	primitive = purple_presence_get_primitive(presence);
@@ -315,7 +315,7 @@
 		}
 	}
 
-	return g_string_free(str, FALSE);
+	return g_string_free_and_steal(str);
 }
 
 static void

mercurial