From 54892975b2b760abfc1d01ad5d0234727de81071 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 1 Oct 2019 01:38:06 -0400 Subject: [PATCH] Use g_list_free_full instead of g_list_foreach+g_list_free. --- finch/gntblist.c | 3 +-- finch/gntlog.c | 3 +-- finch/gntnotify.c | 3 +-- finch/gntplugin.c | 6 ++---- finch/gntprefs.c | 3 +-- finch/plugins/gnthistory.c | 3 +-- finch/plugins/gnttinyurl.c | 13 ++----------- libpurple/account.c | 7 ++----- libpurple/accountopt.c | 14 ++++---------- libpurple/buddylist.c | 3 +-- libpurple/chat.c | 3 +-- libpurple/conversation.c | 3 +-- libpurple/conversationtypes.c | 3 +-- libpurple/notify.c | 3 +-- libpurple/pluginpref.c | 3 +-- libpurple/prefs.c | 12 ++++-------- libpurple/presence.c | 3 +-- libpurple/protocols/jabber/caps.c | 3 +-- libpurple/protocols/jabber/presence.c | 10 ++-------- libpurple/request.c | 25 +++++++------------------ libpurple/roomlist.c | 3 +-- libpurple/signals.c | 4 +--- libpurple/status.c | 4 ++-- pidgin/gtkblist.c | 3 +-- pidgin/gtkconv.c | 6 ++---- pidgin/gtknotify.c | 6 ++---- pidgin/gtkrequest.c | 3 +-- pidgin/gtksavedstatuses.c | 6 ++---- pidgin/pidginlog.c | 3 +-- pidgin/plugins/gevolution/add_buddy_dialog.c | 12 +++--------- pidgin/plugins/gevolution/assoc-buddy.c | 12 +++--------- pidgin/plugins/gevolution/eds-utils.c | 2 +- pidgin/plugins/gevolution/gevolution.c | 3 +-- pidgin/plugins/history.c | 3 +-- 34 files changed, 58 insertions(+), 138 deletions(-) diff --git a/finch/gntblist.c b/finch/gntblist.c index a9a434e527..55289b5618 100644 --- a/finch/gntblist.c +++ b/finch/gntblist.c @@ -1928,8 +1928,7 @@ populate_buddylist(void) static void destroy_status_list(GList *list) { - g_list_foreach(list, (GFunc)g_free, NULL); - g_list_free(list); + g_list_free_full(list, g_free); } static void diff --git a/finch/gntlog.c b/finch/gntlog.c index c5cc4dc02f..f173f963b2 100644 --- a/finch/gntlog.c +++ b/finch/gntlog.c @@ -165,8 +165,7 @@ destroy_cb(GntWidget *w, struct log_viewer_hash *ht) purple_request_close_with_handle(lv); - g_list_foreach(lv->logs, (GFunc)purple_log_free, NULL); - g_list_free(lv->logs); + g_list_free_full(lv->logs, (GDestroyNotify)purple_log_free); g_free(lv->search); g_free(lv); diff --git a/finch/gntnotify.c b/finch/gntnotify.c index dba281765b..d8c687d613 100644 --- a/finch/gntnotify.c +++ b/finch/gntnotify.c @@ -378,8 +378,7 @@ notify_button_activated(GntWidget *widget, PurpleNotifySearchButton *b) list = gnt_tree_get_selection_text_list(GNT_TREE(g_object_get_data(G_OBJECT(widget), "notify-tree"))); b->callback(purple_account_get_connection(account), list, data); - g_list_foreach(list, (GFunc)g_free, NULL); - g_list_free(list); + g_list_free_full(list, g_free); } static void diff --git a/finch/gntplugin.c b/finch/gntplugin.c index 4310f54da5..ca746b4e83 100644 --- a/finch/gntplugin.c +++ b/finch/gntplugin.c @@ -160,8 +160,7 @@ finch_plugin_info_new(const char *first_property, ...) static void free_stringlist(GList *list) { - g_list_foreach(list, (GFunc)g_free, NULL); - g_list_free(list); + g_list_free_full(list, g_free); } static gboolean @@ -325,8 +324,7 @@ reset_plugin_window(GntWidget *window, gpointer null) { GList *list = g_object_get_data(G_OBJECT(plugins.tree), "seen-list"); purple_prefs_set_path_list("/finch/plugins/seen", list); - g_list_foreach(list, (GFunc)g_free, NULL); - g_list_free(list); + g_list_free_full(list, g_free); plugins.window = NULL; plugins.tree = NULL; diff --git a/finch/gntprefs.c b/finch/gntprefs.c index 534dd5161a..5de8e91da2 100644 --- a/finch/gntprefs.c +++ b/finch/gntprefs.c @@ -213,8 +213,7 @@ static Prefs idle[] = static void free_strings(void) { - g_list_foreach(pref_request.freestrings, (GFunc)g_free, NULL); - g_list_free(pref_request.freestrings); + g_list_free_full(pref_request.freestrings, g_free); pref_request.freestrings = NULL; pref_request.showing = FALSE; } diff --git a/finch/plugins/gnthistory.c b/finch/plugins/gnthistory.c index a3dc7d547e..d2471ac1bf 100644 --- a/finch/plugins/gnthistory.c +++ b/finch/plugins/gnthistory.c @@ -127,8 +127,7 @@ static void historize(PurpleConversation *c) purple_conversation_write_system_message(c, "
", mflag); - g_list_foreach(logs, (GFunc)purple_log_free, NULL); - g_list_free(logs); + g_list_free_full(logs, (GDestroyNotify)purple_log_free); } static void diff --git a/finch/plugins/gnttinyurl.c b/finch/plugins/gnttinyurl.c index a25bf9f3b4..6618b1768b 100644 --- a/finch/plugins/gnttinyurl.c +++ b/finch/plugins/gnttinyurl.c @@ -237,11 +237,6 @@ static void url_fetched(PurpleHttpConnection *http_conn, purple_debug_info("TinyURL", "Conversation no longer exists... :(\n"); } -static void free_urls(gpointer data, gpointer null) -{ - g_free(data); -} - static gboolean writing_msg(PurpleConversation *conv, PurpleMessage *msg, gpointer _unused) { GString *t; @@ -252,9 +247,7 @@ static gboolean writing_msg(PurpleConversation *conv, PurpleMessage *msg, gpoint return FALSE; urls = g_object_get_data(G_OBJECT(conv), "TinyURLs"); - if (urls != NULL) /* message was cancelled somewhere? Reset. */ - g_list_foreach(urls, free_urls, NULL); - g_list_free(urls); + g_list_free_full(urls, g_free); urls = extract_urls(purple_message_get_contents(msg)); if (!urls) return FALSE; @@ -362,9 +355,7 @@ static void free_conv_urls(PurpleConversation *conv) { GList *urls = g_object_get_data(G_OBJECT(conv), "TinyURLs"); - if (urls) - g_list_foreach(urls, free_urls, NULL); - g_list_free(urls); + g_list_free_full(urls, g_free); } static void diff --git a/libpurple/account.c b/libpurple/account.c index 23fb7f7ffd..eeb9cf48c1 100644 --- a/libpurple/account.c +++ b/libpurple/account.c @@ -1789,11 +1789,8 @@ purple_account_set_status_types(PurpleAccount *account, GList *status_types) priv = purple_account_get_instance_private(account); /* Out with the old... */ - if (priv->status_types != NULL) - { - g_list_foreach(priv->status_types, (GFunc)purple_status_type_destroy, NULL); - g_list_free(priv->status_types); - } + g_list_free_full(priv->status_types, + (GDestroyNotify)purple_status_type_destroy); /* In with the new... */ priv->status_types = status_types; diff --git a/libpurple/accountopt.c b/libpurple/accountopt.c index 81c6776060..efafd5b372 100644 --- a/libpurple/accountopt.c +++ b/libpurple/accountopt.c @@ -185,11 +185,8 @@ purple_account_option_destroy(PurpleAccountOption *option) } else if (option->type == PURPLE_PREF_STRING_LIST) { - if (option->default_value.list != NULL) - { - g_list_foreach(option->default_value.list, purple_account_option_list_free, NULL); - g_list_free(option->default_value.list); - } + g_list_free_full(option->default_value.list, + (GDestroyNotify)purple_account_option_list_free); } g_free(option); @@ -250,11 +247,8 @@ purple_account_option_set_list(PurpleAccountOption *option, GList *values) g_return_if_fail(option != NULL); g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST); - if (option->default_value.list != NULL) - { - g_list_foreach(option->default_value.list, purple_account_option_list_free, NULL); - g_list_free(option->default_value.list); - } + g_list_free_full(option->default_value.list, + (GDestroyNotify)purple_account_option_list_free); option->default_value.list = values; } diff --git a/libpurple/buddylist.c b/libpurple/buddylist.c index 26f973f905..218ed20843 100644 --- a/libpurple/buddylist.c +++ b/libpurple/buddylist.c @@ -1780,8 +1780,7 @@ purple_blist_find_chat(PurpleAccount *account, const char *name) pce = parts->data; chat_name = g_hash_table_lookup(purple_chat_get_components(chat), pce->identifier); - g_list_foreach(parts, (GFunc)g_free, NULL); - g_list_free(parts); + g_list_free_full(parts, g_free); if (purple_chat_get_account(chat) == account && chat_name != NULL && purple_strequal(purple_normalize(account, chat_name), normname)) { diff --git a/libpurple/chat.c b/libpurple/chat.c index 773313b7e2..cca6606a5b 100644 --- a/libpurple/chat.c +++ b/libpurple/chat.c @@ -89,8 +89,7 @@ const char *purple_chat_get_name_only(PurpleChat *chat) GList *parts = purple_protocol_chat_iface_info(protocol, purple_account_get_connection(priv->account)); pce = parts->data; ret = g_hash_table_lookup(priv->components, pce->identifier); - g_list_foreach(parts, (GFunc)g_free, NULL); - g_list_free(parts); + g_list_free_full(parts, g_free); } return ret; diff --git a/libpurple/conversation.c b/libpurple/conversation.c index 953d703ab9..8f9225d4db 100644 --- a/libpurple/conversation.c +++ b/libpurple/conversation.c @@ -522,8 +522,7 @@ purple_conversation_close_logs(PurpleConversation *conv) g_return_if_fail(PURPLE_IS_CONVERSATION(conv)); priv = purple_conversation_get_instance_private(conv); - g_list_foreach(priv->logs, (GFunc)purple_log_free, NULL); - g_list_free(priv->logs); + g_list_free_full(priv->logs, (GDestroyNotify)purple_log_free); priv->logs = NULL; } diff --git a/libpurple/conversationtypes.c b/libpurple/conversationtypes.c index 47b6132567..6146d795c1 100644 --- a/libpurple/conversationtypes.c +++ b/libpurple/conversationtypes.c @@ -1487,8 +1487,7 @@ purple_chat_conversation_finalize(GObject *object) g_hash_table_destroy(priv->users); priv->users = NULL; - g_list_foreach(priv->ignored, (GFunc)g_free, NULL); - g_list_free(priv->ignored); + g_list_free_full(priv->ignored, g_free); priv->ignored = NULL; g_free(priv->who); diff --git a/libpurple/notify.c b/libpurple/notify.c index c8da332350..7bd9552203 100644 --- a/libpurple/notify.c +++ b/libpurple/notify.c @@ -266,8 +266,7 @@ purple_notify_searchresults_free(PurpleNotifySearchResults *results) for (l = results->rows; l; l = g_list_delete_link(l, l)) { GList *row = l->data; - g_list_foreach(row, (GFunc)g_free, NULL); - g_list_free(row); + g_list_free_full(row, g_free); } for (l = results->columns; l; l = g_list_delete_link(l, l)) { diff --git a/libpurple/pluginpref.c b/libpurple/pluginpref.c index 3fda42397e..80beb25f1c 100644 --- a/libpurple/pluginpref.c +++ b/libpurple/pluginpref.c @@ -65,8 +65,7 @@ purple_plugin_pref_frame_destroy(PurplePluginPrefFrame *frame) { g_return_if_fail(frame != NULL); - g_list_foreach(frame->prefs, (GFunc)purple_plugin_pref_destroy, NULL); - g_list_free(frame->prefs); + g_list_free_full(frame->prefs, (GDestroyNotify)purple_plugin_pref_destroy); g_free(frame); } diff --git a/libpurple/prefs.c b/libpurple/prefs.c index 0f3706ea9e..9fefbd8e19 100644 --- a/libpurple/prefs.c +++ b/libpurple/prefs.c @@ -595,10 +595,8 @@ free_pref_value(struct purple_pref *pref) break; case PURPLE_PREF_STRING_LIST: case PURPLE_PREF_PATH_LIST: - { - g_list_foreach(pref->value.stringlist, (GFunc)g_free, NULL); - g_list_free(pref->value.stringlist); - } break; + g_list_free_full(pref->value.stringlist, g_free); + break; case PURPLE_PREF_NONE: break; } @@ -989,8 +987,7 @@ purple_prefs_set_string_list(const char *name, GList *value) return; } - g_list_foreach(pref->value.stringlist, (GFunc)g_free, NULL); - g_list_free(pref->value.stringlist); + g_list_free_full(pref->value.stringlist, g_free); pref->value.stringlist = NULL; for(tmp = value; tmp; tmp = tmp->next) { @@ -1055,8 +1052,7 @@ purple_prefs_set_path_list(const char *name, GList *value) return; } - g_list_foreach(pref->value.stringlist, (GFunc)g_free, NULL); - g_list_free(pref->value.stringlist); + g_list_free_full(pref->value.stringlist, g_free); pref->value.stringlist = NULL; for(tmp = value; tmp; tmp = tmp->next) diff --git a/libpurple/presence.c b/libpurple/presence.c index 35c2f518fc..215f1c3459 100644 --- a/libpurple/presence.c +++ b/libpurple/presence.c @@ -462,8 +462,7 @@ purple_presence_dispose(GObject *object) purple_presence_get_instance_private(PURPLE_PRESENCE(object)); if (priv->statuses) { - g_list_foreach(priv->statuses, (GFunc)g_object_unref, NULL); - g_list_free(priv->statuses); + g_list_free_full(priv->statuses, (GDestroyNotify)g_object_unref); priv->statuses = NULL; } diff --git a/libpurple/protocols/jabber/caps.c b/libpurple/protocols/jabber/caps.c index a049eb6912..d18923c939 100644 --- a/libpurple/protocols/jabber/caps.c +++ b/libpurple/protocols/jabber/caps.c @@ -908,8 +908,7 @@ gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, field->values); } } else { - g_list_foreach(field->values, (GFunc) g_free, NULL); - g_list_free(field->values); + g_list_free_full(field->values, g_free); } g_free(field->var); diff --git a/libpurple/protocols/jabber/presence.c b/libpurple/protocols/jabber/presence.c index aff5686bc0..c9780edb09 100644 --- a/libpurple/protocols/jabber/presence.c +++ b/libpurple/protocols/jabber/presence.c @@ -492,18 +492,12 @@ jabber_presence_set_capabilities(JabberCapsClientInfo *info, GList *exts, if (!jbr) { g_free(userdata->from); g_free(userdata); - if (exts) { - g_list_foreach(exts, (GFunc)g_free, NULL); - g_list_free(exts); - } + g_list_free_full(exts, g_free); return; } /* Any old jbr->caps.info is owned by the caps code */ - if (jbr->caps.exts) { - g_list_foreach(jbr->caps.exts, (GFunc)g_free, NULL); - g_list_free(jbr->caps.exts); - } + g_list_free_full(jbr->caps.exts, g_free); jbr->caps.info = info; jbr->caps.exts = exts; diff --git a/libpurple/request.c b/libpurple/request.c index d62170ff0a..c495e36a05 100644 --- a/libpurple/request.c +++ b/libpurple/request.c @@ -492,8 +492,8 @@ purple_request_fields_destroy(PurpleRequestFields *fields) g_return_if_fail(fields != NULL); g_strfreev(fields->tab_names); - g_list_foreach(fields->groups, (GFunc)purple_request_field_group_destroy, NULL); - g_list_free(fields->groups); + g_list_free_full(fields->groups, + (GDestroyNotify)purple_request_field_group_destroy); g_list_free(fields->required_fields); g_list_free(fields->validated_fields); g_list_free(fields->autosensitive_fields); @@ -842,8 +842,8 @@ purple_request_field_group_destroy(PurpleRequestFieldGroup *group) g_free(group->title); - g_list_foreach(group->fields, (GFunc)purple_request_field_destroy, NULL); - g_list_free(group->fields); + g_list_free_full(group->fields, + (GDestroyNotify)purple_request_field_destroy); g_free(group); } @@ -966,18 +966,8 @@ purple_request_field_destroy(PurpleRequestField *field) } else if (field->type == PURPLE_REQUEST_FIELD_LIST) { - if (field->u.list.items != NULL) - { - g_list_foreach(field->u.list.items, (GFunc)g_free, NULL); - g_list_free(field->u.list.items); - } - - if (field->u.list.selected != NULL) - { - g_list_foreach(field->u.list.selected, (GFunc)g_free, NULL); - g_list_free(field->u.list.selected); - } - + g_list_free_full(field->u.list.items, g_free); + g_list_free_full(field->u.list.selected, g_free); g_hash_table_destroy(field->u.list.item_data); g_hash_table_destroy(field->u.list.selected_table); } @@ -1669,8 +1659,7 @@ purple_request_field_list_clear_selected(PurpleRequestField *field) if (field->u.list.selected != NULL) { - g_list_foreach(field->u.list.selected, (GFunc)g_free, NULL); - g_list_free(field->u.list.selected); + g_list_free_full(field->u.list.selected, g_free); field->u.list.selected = NULL; } diff --git a/libpurple/roomlist.c b/libpurple/roomlist.c index 3793b2a0d3..a22731622f 100644 --- a/libpurple/roomlist.c +++ b/libpurple/roomlist.c @@ -346,8 +346,7 @@ purple_roomlist_finalize(GObject *object) } g_list_free(priv->rooms); - g_list_foreach(priv->fields, (GFunc)purple_roomlist_field_free, NULL); - g_list_free(priv->fields); + g_list_free_full(priv->fields, (GDestroyNotify)purple_roomlist_field_free); G_OBJECT_CLASS(purple_roomlist_parent_class)->finalize(object); } diff --git a/libpurple/signals.c b/libpurple/signals.c index fcdbecd8f4..c9ab7b90d9 100644 --- a/libpurple/signals.c +++ b/libpurple/signals.c @@ -77,9 +77,7 @@ destroy_instance_data(PurpleInstanceData *instance_data) static void destroy_signal_data(PurpleSignalData *signal_data) { - g_list_foreach(signal_data->handlers, (GFunc)g_free, NULL); - g_list_free(signal_data->handlers); - + g_list_free_full(signal_data->handlers, g_free); g_free(signal_data->value_types); g_free(signal_data); } diff --git a/libpurple/status.c b/libpurple/status.c index 83b9ffb0cd..256f6b785b 100644 --- a/libpurple/status.c +++ b/libpurple/status.c @@ -344,8 +344,8 @@ purple_status_type_destroy(PurpleStatusType *status_type) g_free(status_type->id); g_free(status_type->name); - g_list_foreach(status_type->attrs, (GFunc)purple_status_attribute_destroy, NULL); - g_list_free(status_type->attrs); + g_list_free_full(status_type->attrs, + (GDestroyNotify)purple_status_attribute_destroy); g_free(status_type); } diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c index 2b570f6e52..30c1190766 100644 --- a/pidgin/gtkblist.c +++ b/pidgin/gtkblist.c @@ -2127,8 +2127,7 @@ add_buddies_from_vcard(const char *protocol_id, PurpleGroup *group, GList *list, } } - g_list_foreach(list, (GFunc)g_free, NULL); - g_list_free(list); + g_list_free_full(list, g_free); } static gboolean diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c index 0b864d7e25..c2cddbd868 100644 --- a/pidgin/gtkconv.c +++ b/pidgin/gtkconv.c @@ -236,8 +236,7 @@ close_this_sucker(gpointer data) { PidginConversation *gtkconv = data; GList *list = g_list_copy(gtkconv->convs); - g_list_foreach(list, (GFunc)g_object_unref, NULL); - g_list_free(list); + g_list_free_full(list, g_object_unref); return FALSE; } @@ -4661,8 +4660,7 @@ pidgin_conv_destroy(PurpleConversation *conv) } gtkconv->send_history = g_list_first(gtkconv->send_history); - g_list_foreach(gtkconv->send_history, (GFunc)g_free, NULL); - g_list_free(gtkconv->send_history); + g_list_free_full(gtkconv->send_history, g_free); if (gtkconv->attach_timer) { g_source_remove(gtkconv->attach_timer); diff --git a/pidgin/gtknotify.c b/pidgin/gtknotify.c index f75e445b61..e4dae167d6 100644 --- a/pidgin/gtknotify.c +++ b/pidgin/gtknotify.c @@ -345,8 +345,7 @@ pounce_row_selected_cb(GtkTreeView *tv, GtkTreePath *path, gtk_tree_model_get(GTK_TREE_MODEL(pounce_dialog->treemodel), &iter, PIDGIN_POUNCE_DATA, &pounce_data, -1); - g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); - g_list_free(list); + g_list_free_full(list, (GDestroyNotify)gtk_tree_path_free); pounces = purple_pounces_get_all(); for (; pounces != NULL; pounces = pounces->next) { @@ -499,8 +498,7 @@ searchresults_callback_wrapper_cb(GtkWidget *widget, PidginNotifySearchResultsBu button = bd->button; button->callback(purple_account_get_connection(data->account), row, data->user_data); - g_list_foreach(row, (GFunc)g_free, NULL); - g_list_free(row); + g_list_free_full(row, g_free); } /* copy-paste from gtkrequest.c */ diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c index 6b1d58ef3b..c63ea8b035 100644 --- a/pidgin/gtkrequest.c +++ b/pidgin/gtkrequest.c @@ -1569,8 +1569,7 @@ datasheet_get_selected_row(GtkWidget *sheet_widget) sel_list = gtk_tree_selection_get_selected_rows(selection, &model); gtk_tree_model_get_iter(model, &iter, sel_list->data); - g_list_foreach(sel_list, (GFunc)gtk_tree_path_free, NULL); - g_list_free(sel_list); + g_list_free_full(sel_list, (GDestroyNotify)gtk_tree_path_free); gtk_tree_model_get(model, &iter, 0, &key, -1); diff --git a/pidgin/gtksavedstatuses.c b/pidgin/gtksavedstatuses.c index e28371378f..5c5774c98c 100644 --- a/pidgin/gtksavedstatuses.c +++ b/pidgin/gtksavedstatuses.c @@ -209,8 +209,7 @@ status_window_use_cb(GtkButton *button, StatusWindow *dialog) purple_savedstatus_activate(saved_status); } - g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); - g_list_free(list); + g_list_free_full(list, (GDestroyNotify)gtk_tree_path_free); } static void @@ -247,8 +246,7 @@ static void status_window_delete_cancel_cb(gpointer data) { GList *sel_titles = data; - g_list_foreach(sel_titles, (GFunc) g_free, NULL); - g_list_free(sel_titles); + g_list_free_full(sel_titles, g_free); } static void diff --git a/pidgin/pidginlog.c b/pidgin/pidginlog.c index 7752d18e5d..c18a7ba004 100644 --- a/pidgin/pidginlog.c +++ b/pidgin/pidginlog.c @@ -267,8 +267,7 @@ destroy_cb(GtkWidget *w, gint resp, struct log_viewer_hash *ht) purple_request_close_with_handle(lv); - g_list_foreach(lv->logs, (GFunc)purple_log_free, NULL); - g_list_free(lv->logs); + g_list_free_full(lv->logs, (GDestroyNotify)purple_log_free); g_free(lv->search); diff --git a/pidgin/plugins/gevolution/add_buddy_dialog.c b/pidgin/plugins/gevolution/add_buddy_dialog.c index 6981e3c86e..18d8b05c4a 100644 --- a/pidgin/plugins/gevolution/add_buddy_dialog.c +++ b/pidgin/plugins/gevolution/add_buddy_dialog.c @@ -45,11 +45,7 @@ delete_win_cb(GtkWidget *w, GdkEvent *event, GevoAddBuddyDialog *dialog) { gtk_widget_destroy(dialog->win); - if (dialog->contacts != NULL) - { - g_list_foreach(dialog->contacts, (GFunc)g_object_unref, NULL); - g_list_free(dialog->contacts); - } + g_list_free_full(dialog->contacts, g_object_unref); if (dialog->book != NULL) g_object_unref(dialog->book); @@ -224,8 +220,7 @@ add_ims(GevoAddBuddyDialog *dialog, EContact *contact, const char *name, if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); - g_list_foreach(list, (GFunc)g_free, NULL); - g_list_free(list); + g_list_free_full(list, g_free); } static void @@ -245,8 +240,7 @@ populate_treeview(GevoAddBuddyDialog *dialog, const gchar *uid) if (dialog->contacts != NULL) { - g_list_foreach(dialog->contacts, (GFunc)g_object_unref, NULL); - g_list_free(dialog->contacts); + g_list_free_full(dialog->contacts, g_object_unref); dialog->contacts = NULL; } diff --git a/pidgin/plugins/gevolution/assoc-buddy.c b/pidgin/plugins/gevolution/assoc-buddy.c index aca73d14c2..eda69febab 100644 --- a/pidgin/plugins/gevolution/assoc-buddy.c +++ b/pidgin/plugins/gevolution/assoc-buddy.c @@ -44,11 +44,7 @@ delete_win_cb(GtkWidget *w, GdkEvent *event, GevoAssociateBuddyDialog *dialog) { gtk_widget_destroy(dialog->win); - if (dialog->contacts != NULL) - { - g_list_foreach(dialog->contacts, (GFunc)g_object_unref, NULL); - g_list_free(dialog->contacts); - } + g_list_free_full(dialog->contacts, g_object_unref); g_object_unref(dialog->book); gevo_addrbooks_model_unref(dialog->addrbooks); @@ -147,8 +143,7 @@ populate_treeview(GevoAssociateBuddyDialog *dialog, const gchar *uid) if (dialog->contacts != NULL) { - g_list_foreach(dialog->contacts, (GFunc) g_object_unref, NULL); - g_list_free(dialog->contacts); + g_list_free_full(dialog->contacts, g_object_unref); dialog->contacts = NULL; } @@ -304,8 +299,7 @@ assoc_buddy_cb(GtkWidget *w, GevoAssociateBuddyDialog *dialog) purple_debug_error("evolution", "Error adding contact to book\n"); /* Free the list. */ - g_list_foreach(list, (GFunc)g_free, NULL); - g_list_free(list); + g_list_free_full(list, g_free); delete_win_cb(NULL, NULL, dialog); } diff --git a/pidgin/plugins/gevolution/eds-utils.c b/pidgin/plugins/gevolution/eds-utils.c index fe49c39d2c..40e54eef95 100644 --- a/pidgin/plugins/gevolution/eds-utils.c +++ b/pidgin/plugins/gevolution/eds-utils.c @@ -137,7 +137,7 @@ gevo_run_query_in_source(ESource *source, EBookQuery *query) /* Break off the first contact and free the rest. */ cards->next = NULL; cards2->prev = NULL; - g_list_foreach(cards2, (GFunc)g_object_unref, NULL); + g_list_free_full(cards2, g_object_unref); } /* Free the whole list. */ diff --git a/pidgin/plugins/gevolution/gevolution.c b/pidgin/plugins/gevolution/gevolution.c index 53e892f872..d1e6025b7b 100644 --- a/pidgin/plugins/gevolution/gevolution.c +++ b/pidgin/plugins/gevolution/gevolution.c @@ -110,8 +110,7 @@ update_ims_from_contact(EContact *contact, const char *name, g_free(me); } - g_list_foreach(ims, (GFunc)g_free, NULL); - g_list_free(ims); + g_list_free_full(ims, g_free); } static void diff --git a/pidgin/plugins/history.c b/pidgin/plugins/history.c index 4cbd2901f9..116b31dfcb 100644 --- a/pidgin/plugins/history.c +++ b/pidgin/plugins/history.c @@ -167,8 +167,7 @@ static void historize(PurpleConversation *c) g_object_ref(G_OBJECT(gtkconv->webview)); g_idle_add(_scroll_webview_to_end, gtkconv->webview); - g_list_foreach(logs, (GFunc)purple_log_free, NULL); - g_list_free(logs); + g_list_free_full(logs, (GDestroyNotify)purple_log_free); } static void -- 2.11.4.GIT