libpurple/stringref.c

changeset 40135
3acbe4afeab5
parent 38433
361c801c4536
child 40139
13cfb1168f42
--- a/libpurple/stringref.c	Sun Nov 03 09:22:21 2019 +0000
+++ b/libpurple/stringref.c	Sun Nov 03 20:23:01 2019 +0300
@@ -147,29 +147,18 @@
 
 static void stringref_free(PurpleStringref *stringref)
 {
-#ifdef DEBUG
-	if (REFCOUNT(stringref->ref) != 0) {
-		purple_debug(PURPLE_DEBUG_ERROR, "stringref", "Free of nonzero (%d) ref stringref!\n", REFCOUNT(stringref->ref));
+	if (REFCOUNT(stringref->ref) == 0) {
+		g_free(stringref);
 		return;
 	}
+#ifdef DEBUG
+	purple_debug(PURPLE_DEBUG_ERROR, "stringref", "Free of nonzero (%d) ref stringref!\n", REFCOUNT(stringref->ref));
 #endif /* DEBUG */
-	g_free(stringref);
 }
 
 static gboolean gs_idle_cb(gpointer data)
 {
-	PurpleStringref *ref;
-	GList *del;
-
-	while (gclist != NULL) {
-		ref = gclist->data;
-		if (REFCOUNT(ref->ref) == 0) {
-			stringref_free(ref);
-		}
-		del = gclist;
-		gclist = gclist->next;
-		g_list_free_1(del);
-	}
+	g_list_free_full(gclist, (GDestroyNotify)stringref_free);
 
 	return FALSE;
 }

mercurial