Add a compatiblity layer for g_s?list_free_full and port everything to it.
This avoids a warning from stuff like (GFunc)g_free being an invalid cast.
Testing Done:
Compiled
Reviewed at https://reviews.imfreedom.org/r/498/
--- a/libpurple/account.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/account.c Fri Feb 12 04:07:08 2021 -0600
@@ -28,6 +28,7 @@
@@ -1849,8 +1850,8 @@
/* Out with the old... */
if (account->status_types != NULL)
- g_list_foreach(account->status_types, (GFunc)purple_status_type_destroy, NULL);
- g_list_free(account->status_types);
+ g_list_free_full(account->status_types, + (GDestroyNotify)purple_status_type_destroy); --- a/libpurple/blist.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/blist.c Fri Feb 12 04:07:08 2021 -0600
@@ -27,6 +27,7 @@
#include "conversation.h"
@@ -2422,8 +2423,7 @@
GList *parts = prpl_info->chat_info(purple_account_get_connection(chat->account));
ret = g_hash_table_lookup(chat->components, pce->identifier);
- g_list_foreach(parts, (GFunc)g_free, NULL);
+ g_list_free_full(parts, (GDestroyNotify)g_free); @@ -2570,8 +2570,7 @@
chat_name = g_hash_table_lookup(chat->components,
- g_list_foreach(parts, (GFunc)g_free, NULL);
+ g_list_free_full(parts, (GDestroyNotify)g_free); if (chat->account == account && chat_name != NULL &&
purple_strequal(purple_normalize(account, chat_name), normname)) {
--- a/libpurple/certificate.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/certificate.c Fri Feb 12 04:07:08 2021 -0600
@@ -30,6 +30,7 @@
@@ -957,8 +958,7 @@
x509_ca_initialized = FALSE;
/** TODO: the cert store in the SSL implementation wouldn't be cleared by this */
- g_list_foreach(x509_ca_paths, (GFunc)g_free, NULL);
- g_list_free(x509_ca_paths);
+ g_list_free_full(x509_ca_paths, (GDestroyNotify)g_free); @@ -1796,8 +1796,7 @@
flags |= PURPLE_CERTIFICATE_INVALID_CHAIN;
- g_slist_foreach(ca_crts, (GFunc)purple_certificate_destroy, NULL);
+ g_slist_free_full(ca_crts, (GDestroyNotify)purple_certificate_destroy); g_byte_array_free(last_fpr, TRUE);
x509_tls_cached_check_subject_name(vrq, flags);
--- a/libpurple/conversation.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/conversation.c Fri Feb 12 04:07:08 2021 -0600
@@ -25,6 +25,7 @@
#include "conversation.h"
@@ -288,13 +289,6 @@
-message_history_free(GList *list)
- g_list_foreach(list, (GFunc)free_conv_message, NULL);
/**************************************************************************
**************************************************************************/
@@ -622,11 +616,10 @@
g_hash_table_destroy(conv->u.chat->users);
conv->u.chat->users = NULL;
- g_list_foreach(conv->u.chat->in_room, (GFunc)purple_conv_chat_cb_destroy, NULL);
- g_list_free(conv->u.chat->in_room);
- g_list_foreach(conv->u.chat->ignored, (GFunc)g_free, NULL);
- g_list_free(conv->u.chat->ignored);
+ g_list_free_full(conv->u.chat->in_room, + (GDestroyNotify)purple_conv_chat_cb_destroy); + g_list_free_full(conv->u.chat->ignored, (GDestroyNotify)g_free); conv->u.chat->in_room = NULL;
conv->u.chat->ignored = NULL;
@@ -878,8 +871,7 @@
g_return_if_fail(conv != NULL);
- g_list_foreach(conv->logs, (GFunc)purple_log_free, NULL);
- g_list_free(conv->logs);
+ g_list_free_full(conv->logs, (GDestroyNotify)purple_log_free); @@ -2384,7 +2376,7 @@
void purple_conversation_clear_message_history(PurpleConversation *conv)
GList *list = conv->message_history;
- message_history_free(list);
+ g_list_free_full(list, (GDestroyNotify)free_conv_message); conv->message_history = NULL;
purple_signal_emit(purple_conversations_get_handle(),
--- a/libpurple/desktopitem.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/desktopitem.c Fri Feb 12 04:07:08 2021 -0600
@@ -59,6 +59,7 @@
struct _PurpleDesktopItem {
@@ -1113,15 +1114,12 @@
-free_section (gpointer data, gpointer user_data)
+free_section (Section *section) - Section *section = data;
- g_list_foreach (section->keys, (GFunc)g_free, NULL);
- g_list_free (section->keys);
+ g_list_free_full(section->keys, (GDestroyNotify)g_free); @@ -1237,16 +1235,13 @@
- g_list_foreach (item->languages, (GFunc)g_free, NULL);
- g_list_free (item->languages);
+ g_list_free_full(item->languages, (GDestroyNotify)g_free); - g_list_foreach (item->keys, (GFunc)g_free, NULL);
- g_list_free (item->keys);
+ g_list_free_full(item->keys, (GDestroyNotify)g_free); - g_list_foreach (item->sections, free_section, NULL);
- g_list_free (item->sections);
+ g_list_free_full(item->sections, (GDestroyNotify)free_section); g_hash_table_destroy (item->main_hash);
--- a/libpurple/dnssrv.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/dnssrv.c Fri Feb 12 04:07:08 2021 -0600
@@ -22,6 +22,7 @@
#define _PURPLE_DNSSRV_C_
@@ -539,16 +540,16 @@
purple_debug_error("dnssrv","unable to read txt "
"response length: %s\n", g_strerror(errno));
- g_list_foreach(responses, (GFunc)purple_txt_response_destroy, NULL);
- g_list_free(responses);
+ g_list_free_full(responses, + (GDestroyNotify)purple_txt_response_destroy); if (len > MAX_ADDR_RESPONSE_LEN) {
purple_debug_error("dnssrv", "we've read invalid number\n");
- g_list_foreach(responses, (GFunc)purple_txt_response_destroy, NULL);
- g_list_free(responses);
+ g_list_free_full(responses, + (GDestroyNotify)purple_txt_response_destroy); @@ -562,8 +563,8 @@
"response: %s\n", g_strerror(errno));
purple_txt_response_destroy(res);
- g_list_foreach(responses, (GFunc)purple_txt_response_destroy, NULL);
- g_list_free(responses);
+ g_list_free_full(responses, + (GDestroyNotify)purple_txt_response_destroy); --- a/libpurple/glibcompat.h Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/glibcompat.h Fri Feb 12 04:07:08 2021 -0600
@@ -29,6 +29,30 @@
+#if !GLIB_CHECK_VERSION(2,28,0) +g_list_free_full(GList *l, GDestroyNotify free_func) { + for(ll = l; ll != NULL; ll = ll->next) { +g_slist_free_full(GSList *l, GDestroyNotify free_func) { + for(ll = l; ll != NULL; ll = ll->next) { +#endif /* !GLIB_CHECK_VERSION(2,23,0) */ #if !GLIB_CHECK_VERSION(2,32,0)
# define G_GNUC_BEGIN_IGNORE_DEPRECATIONS
# define G_GNUC_END_IGNORE_DEPRECATIONS
--- a/libpurple/notify.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/notify.c Fri Feb 12 04:07:08 2021 -0600
@@ -27,6 +27,7 @@
static PurpleNotifyUiOps *notify_ui_ops = NULL;
@@ -262,8 +263,7 @@
for (l = results->rows; l; l = g_list_delete_link(l, l)) {
- g_list_foreach(row, (GFunc)g_free, NULL);
+ g_list_free_full(row, (GDestroyNotify)g_free); for (l = results->columns; l; l = g_list_delete_link(l, l)) {
--- a/libpurple/pluginpref.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/pluginpref.c Fri Feb 12 04:07:08 2021 -0600
@@ -26,6 +26,7 @@
@@ -65,8 +66,7 @@
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); --- a/libpurple/prefs.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/prefs.c Fri Feb 12 04:07:08 2021 -0600
@@ -32,8 +32,9 @@
@@ -587,10 +588,8 @@
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);
+ g_list_free_full(pref->value.stringlist, (GDestroyNotify)g_free); @@ -997,8 +996,7 @@
- g_list_foreach(pref->value.stringlist, (GFunc)g_free, NULL);
- g_list_free(pref->value.stringlist);
+ g_list_free_full(pref->value.stringlist, (GDestroyNotify)g_free); pref->value.stringlist = NULL;
for(tmp = value; tmp; tmp = tmp->next) {
@@ -1063,8 +1061,7 @@
- g_list_foreach(pref->value.stringlist, (GFunc)g_free, NULL);
- g_list_free(pref->value.stringlist);
+ g_list_free_full(pref->value.stringlist, (GDestroyNotify)g_free); pref->value.stringlist = NULL;
for(tmp = value; tmp; tmp = tmp->next)
--- a/libpurple/protocols/jabber/jabber.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/protocols/jabber/jabber.c Fri Feb 12 04:07:08 2021 -0600
@@ -31,6 +31,7 @@
#include "conversation.h"
@@ -831,8 +832,7 @@
- g_list_foreach(responses, (GFunc)purple_txt_response_destroy, NULL);
- g_list_free(responses);
+ g_list_free_full(responses, (GDestroyNotify)purple_txt_response_destroy); --- a/libpurple/protocols/jabber/presence.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/protocols/jabber/presence.c Fri Feb 12 04:07:08 2021 -0600
@@ -25,6 +25,7 @@
#include "conversation.h"
@@ -491,16 +492,14 @@
- g_list_foreach(exts, (GFunc)g_free, NULL);
+ g_list_free_full(exts, g_free); /* Any old jbr->caps.info is owned by the caps code */
- 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); --- a/libpurple/request.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/request.c Fri Feb 12 04:07:08 2021 -0600
@@ -62,8 +62,8 @@
g_return_if_fail(fields != NULL);
- 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_hash_table_destroy(fields->fields);
@@ -291,8 +291,8 @@
- 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); @@ -376,22 +376,19 @@
if (field->u.choice.labels != NULL)
- g_list_foreach(field->u.choice.labels, (GFunc)g_free, NULL);
- g_list_free(field->u.choice.labels);
+ g_list_free_full(field->u.choice.labels, (GDestroyNotify)g_free); 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);
+ g_list_free_full(field->u.list.items, (GDestroyNotify)g_free); 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, (GDestroyNotify)g_free); g_hash_table_destroy(field->u.list.item_data);
@@ -919,8 +916,7 @@
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, (GDestroyNotify)g_free); field->u.list.selected = NULL;
--- a/libpurple/roomlist.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/roomlist.c Fri Feb 12 04:07:08 2021 -0600
@@ -29,6 +29,7 @@
@@ -109,8 +110,8 @@
g_list_free(list->rooms);
- g_list_foreach(list->fields, (GFunc)purple_roomlist_field_destroy, NULL);
- g_list_free(list->fields);
+ g_list_free_full(list->fields, + (GDestroyNotify)purple_roomlist_field_destroy); --- a/libpurple/signals.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/signals.c Fri Feb 12 04:07:08 2021 -0600
@@ -27,6 +27,7 @@
@@ -84,8 +85,7 @@
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, (GDestroyNotify)g_free); if (signal_data->values != NULL)
--- a/libpurple/status.c Thu Feb 11 23:57:10 2021 -0600
+++ b/libpurple/status.c Fri Feb 12 04:07:08 2021 -0600
@@ -31,6 +31,7 @@
@@ -296,8 +297,8 @@
g_free(status_type->name);
g_free(status_type->primary_attr_id);
- g_list_foreach(status_type->attrs, (GFunc)purple_status_attr_destroy, NULL);
- g_list_free(status_type->attrs);
+ g_list_free_full(status_type->attrs, + (GDestroyNotify)purple_status_attr_destroy); PURPLE_DBUS_UNREGISTER_POINTER(status_type);
@@ -1174,8 +1175,7 @@
g_free(presence->u.chat.user);
- g_list_foreach(presence->statuses, (GFunc)purple_status_destroy, NULL);
- g_list_free(presence->statuses);
+ g_list_free_full(presence->statuses, (GDestroyNotify)purple_status_destroy); g_hash_table_destroy(presence->status_table);
--- a/pidgin/gtkblist.c Thu Feb 11 23:57:10 2021 -0600
+++ b/pidgin/gtkblist.c Fri Feb 12 04:07:08 2021 -0600
@@ -31,6 +31,7 @@
@@ -2130,8 +2131,7 @@
- g_list_foreach(list, (GFunc)g_free, NULL);
+ g_list_free_full(list, (GDestroyNotify)g_free); --- a/pidgin/gtkconv.c Thu Feb 11 23:57:10 2021 -0600
+++ b/pidgin/gtkconv.c Fri Feb 12 04:07:08 2021 -0600
@@ -219,8 +219,7 @@
PidginConversation *gtkconv = data;
GList *list = g_list_copy(gtkconv->convs);
- g_list_foreach(list, (GFunc)purple_conversation_destroy, NULL);
+ g_list_free_full(list, (GDestroyNotify)purple_conversation_destroy); @@ -5545,8 +5544,7 @@
gtk_object_sink(GTK_OBJECT(gtkconv->tooltips));
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, (GDestroyNotify)g_free); if (gtkconv->attach.timer) {
g_source_remove(gtkconv->attach.timer);
--- a/pidgin/gtkimhtml.c Thu Feb 11 23:57:10 2021 -0600
+++ b/pidgin/gtkimhtml.c Fri Feb 12 04:07:08 2021 -0600
@@ -31,6 +31,7 @@
@@ -5692,8 +5693,7 @@
GList *children = gtk_container_get_children(GTK_CONTAINER(wids->data));
- g_list_foreach(children, (GFunc)gtk_widget_destroy, NULL);
+ g_list_free_full(children, (GDestroyNotify)gtk_widget_destroy); gtk_container_add(GTK_CONTAINER(wids->data), icon);
gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor);
--- a/pidgin/gtklog.c Thu Feb 11 23:57:10 2021 -0600
+++ b/pidgin/gtklog.c Fri Feb 12 04:07:08 2021 -0600
@@ -28,6 +28,7 @@
@@ -216,8 +217,7 @@
purple_request_close_with_handle(lv);
- g_list_foreach(lv->logs, (GFunc)purple_log_free, NULL);
+ g_list_free_full(lv->logs, (GDestroyNotify)purple_log_free); --- a/pidgin/gtkmain.c Thu Feb 11 23:57:10 2021 -0600
+++ b/pidgin/gtkmain.c Fri Feb 12 04:07:08 2021 -0600
@@ -31,6 +31,7 @@
@@ -287,8 +288,7 @@
gtk_window_set_default_icon_list(icons);
- g_list_foreach(icons, (GFunc)g_object_unref, NULL);
+ g_list_free_full(icons, (GDestroyNotify)g_object_unref); --- a/pidgin/gtknotify.c Thu Feb 11 23:57:10 2021 -0600
+++ b/pidgin/gtknotify.c Fri Feb 12 04:07:08 2021 -0600
@@ -31,6 +31,7 @@
@@ -349,8 +350,7 @@
gtk_tree_model_get(GTK_TREE_MODEL(pounce_dialog->treemodel), &iter,
PIDGIN_POUNCE_DATA, &pounce_data,
- g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free_full(list, (GDestroyNotify)gtk_tree_path_free); pounces = purple_pounces_get_all();
for (; pounces != NULL; pounces = pounces->next) {
@@ -482,8 +482,7 @@
button->callback(purple_account_get_connection(data->account), row, data->user_data);
- g_list_foreach(row, (GFunc)g_free, NULL);
+ g_list_free_full(row, (GDestroyNotify)g_free); --- a/pidgin/gtksavedstatuses.c Thu Feb 11 23:57:10 2021 -0600
+++ b/pidgin/gtksavedstatuses.c Fri Feb 12 04:07:08 2021 -0600
@@ -27,6 +27,7 @@
#include "savedstatuses.h"
@@ -211,8 +212,7 @@
purple_savedstatus_activate(saved_status);
- g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free_full(list, (GDestroyNotify)gtk_tree_path_free); @@ -249,8 +249,7 @@
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, (GDestroyNotify)g_free); --- a/pidgin/plugins/history.c Thu Feb 11 23:57:10 2021 -0600
+++ b/pidgin/plugins/history.c Fri Feb 12 04:07:08 2021 -0600
@@ -6,6 +6,7 @@
#include "conversation.h"
@@ -150,8 +151,7 @@
g_object_ref(G_OBJECT(gtkconv->imhtml));
g_idle_add(_scroll_imhtml_to_end, gtkconv->imhtml);
- g_list_foreach(logs, (GFunc)purple_log_free, NULL);
+ g_list_free_full(logs, (GDestroyNotify)purple_log_free);