pidgin/pidgin

Reduce lists iterations

16 months ago, qarkai
3acbe4afeab5
Parents df0db1029678
Children 11764e84328d
Reduce lists iterations
--- a/libpurple/protocols/jabber/buddy.c Sun Nov 03 09:22:21 2019 +0000
+++ b/libpurple/protocols/jabber/buddy.c Sun Nov 03 20:23:01 2019 +0300
@@ -708,6 +708,7 @@
if (jbi->timeout_handle > 0)
g_source_remove(jbi->timeout_handle);
+ g_slist_free(jbi->ids);
g_free(jbi->jid);
g_hash_table_destroy(jbi->resources);
g_free(jbi->last_message);
@@ -1459,22 +1460,8 @@
void jabber_buddy_remove_all_pending_buddy_info_requests(JabberStream *js)
{
- if (js->pending_buddy_info_requests)
- {
- JabberBuddyInfo *jbi;
- GSList *l = js->pending_buddy_info_requests;
- while (l) {
- jbi = l->data;
-
- g_slist_free(jbi->ids);
- jabber_buddy_info_destroy(jbi);
-
- l = l->next;
- }
-
- g_slist_free(js->pending_buddy_info_requests);
- js->pending_buddy_info_requests = NULL;
- }
+ g_slist_free_full(js->pending_buddy_info_requests, (GDestroyNotify)jabber_buddy_info_destroy);
+ js->pending_buddy_info_requests = NULL;
}
static gboolean jabber_buddy_get_info_timeout(gpointer data)
--- a/libpurple/protocols/novell/nmrtf.c Sun Nov 03 09:22:21 2019 +0000
+++ b/libpurple/protocols/novell/nmrtf.c Sun Nov 03 20:23:01 2019 +0300
@@ -239,20 +239,18 @@
return NULL;
}
+static void
+nm_rtf_font_free(NMRtfFont *font)
+{
+ g_free(font->name);
+ g_free(font);
+}
+
void
nm_rtf_deinit(NMRtfContext *ctx)
{
- GSList *node;
- NMRtfFont *font;
-
if (ctx) {
- for (node = ctx->font_table; node; node = node->next) {
- font = node->data;
- g_free(font->name);
- g_free(font);
- node->data = NULL;
- }
- g_slist_free(ctx->font_table);
+ g_slist_free_full(ctx->font_table, (GDestroyNotify)nm_rtf_font_free);
g_slist_free_full(ctx->saved, g_free);
g_string_free(ctx->ansi, TRUE);
g_string_free(ctx->output, TRUE);
--- 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;
}
--- a/pidgin/gtksmiley-theme.c Sun Nov 03 09:22:21 2019 +0000
+++ b/pidgin/gtksmiley-theme.c Sun Nov 03 20:23:01 2019 +0300
@@ -91,33 +91,31 @@
******************************************************************************/
static void
+pidgin_smiley_theme_index_smiley_free(PidginSmileyThemeIndexSmiley *smiley)
+{
+ g_free(smiley->file);
+ g_list_free_full(smiley->shortcuts, g_free);
+ g_free(smiley);
+}
+
+static void
+pidgin_smiley_theme_index_protocol_free(PidginSmileyThemeIndexProtocol *proto)
+{
+ g_free(proto->name);
+ g_list_free_full(proto->smileys, (GDestroyNotify)pidgin_smiley_theme_index_smiley_free);
+ g_free(proto);
+}
+
+static void
pidgin_smiley_theme_index_free(PidginSmileyThemeIndex *index)
{
- GList *it, *it2;
-
g_return_if_fail(index != NULL);
g_free(index->name);
g_free(index->desc);
g_free(index->icon);
g_free(index->author);
-
- for (it = index->protocols; it; it = g_list_next(it)) {
- PidginSmileyThemeIndexProtocol *proto = it->data;
-
- g_free(proto->name);
- for (it2 = proto->smileys; it2; it2 = g_list_next(it2)) {
- PidginSmileyThemeIndexSmiley *smiley = it2->data;
-
- g_free(smiley->file);
- g_list_free_full(smiley->shortcuts, g_free);
- g_free(smiley);
- }
- g_list_free(proto->smileys);
- g_free(proto);
- }
- g_list_free(index->protocols);
-
+ g_list_free_full(index->protocols, (GDestroyNotify)pidgin_smiley_theme_index_protocol_free);
g_free(index);
}