Use g_clear_* helpers where useful
That is:
* when the variable is set to `NULL` right after freeing
* when the variable is checked for non-`NULL` before freeing
* when the variable is a global (because they should be set to `NULL`, even if we don't really claim that things can be re-init'd)
Testing Done:
Compiled, and ran tests in valgrind.
Reviewed at https://reviews.imfreedom.org/r/2369/
--- a/finch/gntaccount.c Mon Mar 20 23:06:42 2023 -0500
+++ b/finch/gntaccount.c Tue Mar 21 00:39:45 2023 -0500
@@ -380,11 +380,7 @@
gnt_box_set_fill(GNT_BOX(vbox), TRUE);
- if (dialog->protocol_entries)
- g_list_free(dialog->protocol_entries);
- dialog->protocol_entries = NULL;
+ g_clear_list(&dialog->protocol_entries, NULL); vbox = dialog->protocols;
@@ -949,8 +945,6 @@
-finch_accounts_uninit(void)
- gnt_widget_destroy(accounts.window);
+finch_accounts_uninit(void) { + g_clear_pointer(&accounts.window, gnt_widget_destroy); --- a/finch/gntblist.c Mon Mar 20 23:06:42 2023 -0500
+++ b/finch/gntblist.c Tue Mar 21 00:39:45 2023 -0500
@@ -1844,13 +1844,11 @@
g_source_remove(ggblist->typing);
remove_peripherals(ggblist);
- g_list_free(ggblist->tagged);
+ g_clear_list(&ggblist->tagged, NULL); if (ggblist->new_group_timeout)
g_source_remove(ggblist->new_group_timeout);
- if (ggblist->new_group)
- g_list_free(ggblist->new_group);
+ g_clear_list(&ggblist->new_group, NULL); --- a/finch/gntconn.c Mon Mar 20 23:06:42 2023 -0500
+++ b/finch/gntconn.c Tue Mar 21 00:39:45 2023 -0500
@@ -145,5 +145,5 @@
g_signal_handlers_disconnect_by_func(manager,
G_CALLBACK(account_removed_cb), NULL);
- g_hash_table_destroy(hash);
+ g_clear_pointer(&hash, g_hash_table_destroy); --- a/finch/gntnotify.c Mon Mar 20 23:06:42 2023 -0500
+++ b/finch/gntnotify.c Tue Mar 21 00:39:45 2023 -0500
@@ -424,9 +424,6 @@
-finch_notify_uninit(void)
- g_hash_table_destroy(userinfo);
+finch_notify_uninit(void) { + g_clear_pointer(&userinfo, g_hash_table_destroy);
--- a/finch/gntprefs.c Mon Mar 20 23:06:42 2023 -0500
+++ b/finch/gntprefs.c Tue Mar 21 00:39:45 2023 -0500
@@ -229,8 +229,7 @@
- g_list_free_full(pref_request.freestrings, g_free);
- pref_request.freestrings = NULL;
+ g_clear_list(&pref_request.freestrings, g_free); pref_request.showing = FALSE;
--- a/finch/plugins/gnttinyurl/gnttinyurl.c Mon Mar 20 23:06:42 2023 -0500
+++ b/finch/plugins/gnttinyurl/gnttinyurl.c Tue Mar 21 00:39:45 2023 -0500
@@ -552,8 +552,7 @@
soup_session_abort(session);
g_clear_object(&session);
- g_hash_table_destroy(tinyurl_cache);
+ g_clear_pointer(&tinyurl_cache, g_hash_table_destroy); --- a/finch/plugins/grouping/grouping.c Mon Mar 20 23:06:42 2023 -0500
+++ b/finch/plugins/grouping/grouping.c Tue Mar 21 00:39:45 2023 -0500
@@ -250,8 +250,7 @@
nested_group_uninit(void)
- g_hash_table_destroy(groups);
+ g_clear_pointer(&groups, g_hash_table_destroy); --- a/libpurple/buddyicon.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/buddyicon.c Tue Mar 21 00:39:45 2023 -0500
@@ -1138,9 +1138,7 @@
g_hash_table_destroy(icon_data_cache);
g_hash_table_destroy(icon_file_cache);
g_hash_table_destroy(pointer_icon_cache);
+ g_clear_pointer(&cache_dir, g_free); --- a/libpurple/buddylist.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/buddylist.c Tue Mar 21 00:39:45 2023 -0500
@@ -2179,16 +2179,12 @@
purple_debug_info("buddylist", "Destroying");
- g_hash_table_destroy(buddies_cache);
- g_hash_table_destroy(groups_cache);
+ g_clear_pointer(&buddies_cache, g_hash_table_destroy); + g_clear_pointer(&groups_cache, g_hash_table_destroy); g_clear_object(&purplebuddylist);
- g_free(localized_default_group_name);
- localized_default_group_name = NULL;
+ g_clear_pointer(&localized_default_group_name, g_free); purple_signals_disconnect_by_handle(purple_blist_get_handle());
purple_signals_unregister_by_instance(purple_blist_get_handle());
--- a/libpurple/cmds.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/cmds.c Tue Mar 21 00:39:45 2023 -0500
@@ -392,7 +392,6 @@
purple_signals_unregister_by_instance(purple_cmds_get_handle());
- g_list_free_full(cmds, (GDestroyNotify)purple_cmd_free);
+ g_clear_list(&cmds, (GDestroyNotify)purple_cmd_free); --- a/libpurple/image-store.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/image-store.c Tue Mar 21 00:39:45 2023 -0500
@@ -219,13 +219,10 @@
_purple_image_store_uninit(void)
- g_slist_free_full(perm_images, g_object_unref);
+ g_clear_slist(&perm_images, g_object_unref); g_hash_table_foreach(temp_images, cancel_temporary, NULL);
- g_hash_table_destroy(temp_images);
+ g_clear_pointer(&temp_images, g_hash_table_destroy); - g_hash_table_destroy(id_to_image);
+ g_clear_pointer(&id_to_image, g_hash_table_destroy); --- a/libpurple/mediamanager.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/mediamanager.c Tue Mar 21 00:39:45 2023 -0500
@@ -201,10 +201,8 @@
g_list_free_full(priv->private_medias, g_object_unref);
g_list_free_full(priv->elements, g_object_unref);
g_clear_pointer(&priv->video_caps, gst_caps_unref);
- if (priv->appdata_info) {
- g_list_free_full(priv->appdata_info,
- (GDestroyNotify)free_appdata_info_locked);
+ g_clear_list(&priv->appdata_info, + (GDestroyNotify)free_appdata_info_locked); g_mutex_clear (&priv->appdata_mutex);
if (priv->device_monitor) {
gst_device_monitor_stop(priv->device_monitor);
--- a/libpurple/plugins/idle/idle.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/plugins/idle/idle.c Tue Mar 21 00:39:45 2023 -0500
@@ -256,8 +256,7 @@
/* freeing the list here will cause segfaults if the user idles an account
* after the list is freed */
g_list_foreach(idled_accts, (GFunc)set_idle_time, GINT_TO_POINTER(0));
- g_list_free(idled_accts);
+ g_clear_list(&idled_accts, NULL); /******************************************************************************
--- a/libpurple/prefs.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/prefs.c Tue Mar 21 00:39:45 2023 -0500
@@ -923,8 +923,7 @@
- g_list_free_full(pref->value.stringlist, g_free);
- pref->value.stringlist = NULL;
+ g_clear_list(&pref->value.stringlist, g_free); for(tmp = value; tmp; tmp = tmp->next) {
if(tmp->data != NULL && !g_utf8_validate(tmp->data, -1, NULL)) {
@@ -1489,6 +1488,5 @@
- g_hash_table_destroy(prefs_hash);
+ g_clear_pointer(&prefs_hash, g_hash_table_destroy); --- a/libpurple/protocols/facebook/facebook.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/facebook/facebook.c Tue Mar 21 00:39:45 2023 -0500
@@ -1672,7 +1672,7 @@
- g_slist_free_full(fb_cmds, fb_cmds_unregister_free);
+ g_clear_slist(&fb_cmds, fb_cmds_unregister_free); static GPluginPluginInfo *
--- a/libpurple/protocols/gg/chat.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/gg/chat.c Tue Mar 21 00:39:45 2023 -0500
@@ -197,8 +197,7 @@
ggp_chat_join_id(gc, *id_p);
- g_slist_free_full(sdata->pending_joins, g_free);
- sdata->pending_joins = NULL;
+ g_clear_slist(&sdata->pending_joins, g_free); } else if (ev->type == GG_EVENT_CHAT_INFO_UPDATE) {
const struct gg_event_chat_info_update *eciu =
&ev->event.chat_info_update;
--- a/libpurple/protocols/gg/message-prpl.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/gg/message-prpl.c Tue Mar 21 00:39:45 2023 -0500
@@ -590,8 +590,7 @@
- g_hash_table_destroy(styles);
+ g_clear_pointer(&styles, g_hash_table_destroy); g_hash_table_destroy(attribs);
else if ((tag == GGP_HTML_TAG_FONT || tag == GGP_HTML_TAG_SPAN
--- a/libpurple/protocols/gg/roster.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/gg/roster.c Tue Mar 21 00:39:45 2023 -0500
@@ -148,16 +148,11 @@
- purple_xmlnode_free(content->xml);
- if (content->contact_nodes)
- g_hash_table_destroy(content->contact_nodes);
- if (content->group_nodes)
- g_hash_table_destroy(content->group_nodes);
- if (content->group_ids)
- g_hash_table_destroy(content->group_ids);
- if (content->group_names)
- g_hash_table_destroy(content->group_names);
+ g_clear_pointer(&content->xml, purple_xmlnode_free); + g_clear_pointer(&content->contact_nodes, g_hash_table_destroy); + g_clear_pointer(&content->group_nodes, g_hash_table_destroy); + g_clear_pointer(&content->group_ids, g_hash_table_destroy); + g_clear_pointer(&content->group_names, g_hash_table_destroy); g_free(content->bots_group_id);
@@ -1062,8 +1057,7 @@
ggp_roster_set_synchronized(gc, buddy, FALSE);
- g_list_free_full(rdata->sent_updates, ggp_roster_change_free);
- rdata->sent_updates = NULL;
+ g_clear_list(&rdata->sent_updates, ggp_roster_change_free); /* bump roster version or update it, if needed */
g_return_if_fail(content != NULL);
--- a/libpurple/protocols/gg/servconn.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/gg/servconn.c Tue Mar 21 00:39:45 2023 -0500
@@ -65,7 +65,7 @@
void ggp_servconn_cleanup(void)
- g_list_free_full(global_data.server_history, &g_free);
+ g_clear_list(&global_data.server_history, g_free); void ggp_servconn_add_server(const gchar *server)
--- a/libpurple/protocols/irc/parse.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/irc/parse.c Tue Mar 21 00:39:45 2023 -0500
@@ -240,7 +240,7 @@
void irc_unregister_commands(void)
- g_slist_free_full(cmds, (GDestroyNotify)(gpointer)purple_cmd_unregister);
+ g_clear_slist(&cmds, (GDestroyNotify)(gpointer)purple_cmd_unregister); static char *irc_send_convert(struct irc_conn *irc, const char *string)
--- a/libpurple/protocols/jabber/adhoccommands.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/adhoccommands.c Tue Mar 21 00:39:45 2023 -0500
@@ -73,8 +73,7 @@
/* since the list we just received is complete, wipe the old one */
- g_list_free_full(jbr->commands, (GDestroyNotify)jabber_adhoc_commands_free);
+ g_clear_list(&jbr->commands, (GDestroyNotify)jabber_adhoc_commands_free); for(item = query->child; item; item = item->next) {
JabberAdHocCommands *cmd;
@@ -248,8 +247,7 @@
/* clean current list (just in case there is one) */
- g_list_free_full(js->commands, (GDestroyNotify)jabber_adhoc_commands_free);
+ g_clear_list(&js->commands, (GDestroyNotify)jabber_adhoc_commands_free); for(item = query->child; item; item = item->next) {
--- a/libpurple/protocols/jabber/auth.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/auth.c Tue Mar 21 00:39:45 2023 -0500
@@ -553,6 +553,5 @@
void jabber_auth_uninit(void)
- g_slist_free(auth_mechs);
+ g_clear_slist(&auth_mechs, NULL); --- a/libpurple/protocols/jabber/bosh.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/bosh.c Tue Mar 21 00:39:45 2023 -0500
@@ -84,8 +84,7 @@
void jabber_bosh_uninit(void)
- g_free(jabber_bosh_useragent);
- jabber_bosh_useragent = NULL;
+ g_clear_pointer(&jabber_bosh_useragent, g_free); PurpleJabberBOSHConnection*
--- a/libpurple/protocols/jabber/buddy.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/buddy.c Tue Mar 21 00:39:45 2023 -0500
@@ -1446,8 +1446,8 @@
void jabber_buddy_remove_all_pending_buddy_info_requests(JabberStream *js)
- g_slist_free_full(js->pending_buddy_info_requests, (GDestroyNotify)jabber_buddy_info_destroy);
- js->pending_buddy_info_requests = NULL;
+ g_clear_slist(&js->pending_buddy_info_requests, + (GDestroyNotify)jabber_buddy_info_destroy); static gboolean jabber_buddy_get_info_timeout(gpointer data)
--- a/libpurple/protocols/jabber/caps.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/caps.c Tue Mar 21 00:39:45 2023 -0500
@@ -207,8 +207,7 @@
do_jabber_caps_store(NULL);
- g_hash_table_destroy(capstable);
+ g_clear_pointer(&capstable, g_hash_table_destroy); --- a/libpurple/protocols/jabber/data.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/data.c Tue Mar 21 00:39:45 2023 -0500
@@ -468,8 +468,7 @@
if (purple_debug_is_verbose())
purple_debug_info("jabber", "destroying hash tables for data objects");
- g_hash_table_destroy(local_data_by_alt);
- g_hash_table_destroy(local_data_by_cid);
- g_hash_table_destroy(remote_data_by_cid);
- local_data_by_alt = local_data_by_cid = remote_data_by_cid = NULL;
+ g_clear_pointer(&local_data_by_alt, g_hash_table_destroy); + g_clear_pointer(&local_data_by_cid, g_hash_table_destroy); + g_clear_pointer(&remote_data_by_cid, g_hash_table_destroy); --- a/libpurple/protocols/jabber/disco.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/disco.c Tue Mar 21 00:39:45 2023 -0500
@@ -462,8 +462,7 @@
if (type == JABBER_IQ_ERROR)
- g_list_free_full(js->chat_servers, g_free);
- js->chat_servers = NULL;
+ g_clear_list(&js->chat_servers, g_free); query = purple_xmlnode_get_child(packet, "query");
--- a/libpurple/protocols/jabber/ibb.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/ibb.c Tue Mar 21 00:39:45 2023 -0500
@@ -509,9 +509,6 @@
- g_hash_table_destroy(jabber_ibb_sessions);
- g_list_free(open_handlers);
- jabber_ibb_sessions = NULL;
+ g_clear_pointer(&jabber_ibb_sessions, g_hash_table_destroy); + g_clear_list(&open_handlers, NULL);
--- a/libpurple/protocols/jabber/iq.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/iq.c Tue Mar 21 00:39:45 2023 -0500
@@ -557,7 +557,6 @@
void jabber_iq_uninit(void)
- g_hash_table_destroy(iq_handlers);
- g_hash_table_destroy(signal_iq_handlers);
- iq_handlers = signal_iq_handlers = NULL;
+ g_clear_pointer(&iq_handlers, g_hash_table_destroy); + g_clear_pointer(&signal_iq_handlers, g_hash_table_destroy); --- a/libpurple/protocols/jabber/jabber.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/jabber.c Tue Mar 21 00:39:45 2023 -0500
@@ -1025,12 +1025,9 @@
- g_hash_table_destroy(js->iq_callbacks);
- g_hash_table_destroy(js->buddies);
- g_hash_table_destroy(js->chats);
+ g_clear_pointer(&js->iq_callbacks, g_hash_table_destroy); + g_clear_pointer(&js->buddies, g_hash_table_destroy); + g_clear_pointer(&js->chats, g_hash_table_destroy); g_list_free_full(js->chat_servers, g_free);
@@ -1042,8 +1039,7 @@
- jabber_id_free(js->user);
+ g_clear_pointer(&js->user, jabber_id_free); g_free(js->initial_avatar_hash);
@@ -2620,9 +2616,7 @@
+ g_clear_list(&specific, NULL); @@ -2980,11 +2974,10 @@
G_CALLBACK(jabber_caps_broadcast_change), NULL);
- g_list_free_full(jabber_features, (GDestroyNotify)jabber_feature_free);
- g_list_free_full(jabber_identities, (GDestroyNotify)jabber_identity_free);
- g_hash_table_destroy(jabber_cmds);
+ g_clear_list(&jabber_features, (GDestroyNotify)jabber_feature_free); + g_clear_list(&jabber_identities, (GDestroyNotify)jabber_identity_free); + g_clear_pointer(&jabber_cmds, g_hash_table_destroy); static void jabber_init_protocol(PurpleProtocol *protocol)
--- a/libpurple/protocols/jabber/jingle/rtp.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/jingle/rtp.c Tue Mar 21 00:39:45 2023 -0500
@@ -821,8 +821,7 @@
+ g_clear_list(&iter, NULL); --- a/libpurple/protocols/jabber/pep.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/pep.c Tue Mar 21 00:39:45 2023 -0500
@@ -46,8 +46,7 @@
* cleanup of removing the handler and feature are handled here and by
* jabber_features_destroy() in jabber.c
- g_hash_table_destroy(pep_handlers);
+ g_clear_pointer(&pep_handlers, g_hash_table_destroy); --- a/libpurple/protocols/jabber/presence.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/protocols/jabber/presence.c Tue Mar 21 00:39:45 2023 -0500
@@ -1244,6 +1244,5 @@
void jabber_presence_uninit(void)
- g_hash_table_destroy(presence_handlers);
- presence_handlers = NULL;
+ g_clear_pointer(&presence_handlers , g_hash_table_destroy); --- a/libpurple/purplechatconversation.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/purplechatconversation.c Tue Mar 21 00:39:45 2023 -0500
@@ -261,8 +261,7 @@
g_clear_pointer(&priv->users, g_hash_table_destroy);
- g_list_free_full(priv->ignored, g_free);
+ g_clear_list(&priv->ignored, g_free); g_clear_pointer(&priv->who, g_free);
g_clear_pointer(&priv->topic, g_free);
--- a/libpurple/purpletags.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/purpletags.c Tue Mar 21 00:39:45 2023 -0500
@@ -40,10 +40,7 @@
purple_tags_dispose(GObject *obj) {
PurpleTags *tags = PURPLE_TAGS(obj);
- if(tags->tags != NULL) {
- g_list_free_full(tags->tags, g_free);
+ g_clear_list(&tags->tags, g_free); G_OBJECT_CLASS(purple_tags_parent_class)->dispose(obj);
--- a/libpurple/request-datasheet.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/request-datasheet.c Tue Mar 21 00:39:45 2023 -0500
@@ -109,8 +109,7 @@
g_list_free_full(sheet->record_list,
(GDestroyNotify)purple_request_datasheet_record_free);
- if (sheet->marked_for_rem != NULL)
- g_hash_table_destroy(sheet->marked_for_rem);
+ g_clear_pointer(&sheet->marked_for_rem, g_hash_table_destroy); @@ -381,9 +380,8 @@
g_return_if_fail(sheet != NULL);
- g_list_free_full(sheet->record_list,
- (GDestroyNotify)purple_request_datasheet_record_free);
- sheet->record_list = NULL;
+ g_clear_list(&sheet->record_list, + (GDestroyNotify)purple_request_datasheet_record_free); g_hash_table_remove_all(sheet->record_li_by_key);
purple_signal_emit(sheet, "record-changed", sheet, NULL);
@@ -394,8 +392,7 @@
- if (sheet->marked_for_rem != NULL)
- g_hash_table_destroy(sheet->marked_for_rem);
+ g_clear_pointer(&sheet->marked_for_rem, g_hash_table_destroy); sheet->marked_for_rem = g_hash_table_new(g_direct_hash, g_direct_equal);
it = purple_request_datasheet_get_records(sheet);
--- a/libpurple/request/purplerequestfieldlist.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/request/purplerequestfieldlist.c Tue Mar 21 00:39:45 2023 -0500
@@ -216,8 +216,7 @@
purple_request_field_list_clear_selected(PurpleRequestFieldList *field) {
g_return_if_fail(PURPLE_IS_REQUEST_FIELD_LIST(field));
- g_list_free_full(field->selected, g_free);
- field->selected = NULL;
+ g_clear_list(&field->selected, g_free); g_hash_table_remove_all(field->selected_table);
g_object_notify(G_OBJECT(field), "valid");
--- a/libpurple/savedstatuses.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/savedstatuses.c Tue Mar 21 00:39:45 2023 -0500
@@ -1268,11 +1268,9 @@
- g_list_free_full(saved_statuses, (GDestroyNotify)free_saved_status);
+ g_clear_list(&saved_statuses, (GDestroyNotify)free_saved_status); - g_hash_table_destroy(creation_times);
+ g_clear_pointer(&creation_times, g_hash_table_destroy); g_signal_handlers_disconnect_by_func(manager,
G_CALLBACK(purple_savedstatus_unset_all_substatuses),
--- a/libpurple/server.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/server.c Tue Mar 21 00:39:45 2023 -0500
@@ -457,8 +457,7 @@
static void chat_invite_data_free(struct chat_invite_data *cid)
- g_hash_table_destroy(cid->components);
+ g_clear_pointer(&cid->components, g_hash_table_destroy); --- a/libpurple/signals.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/signals.c Tue Mar 21 00:39:45 2023 -0500
@@ -475,8 +475,7 @@
g_return_if_fail(instance_table != NULL);
- g_hash_table_destroy(instance_table);
+ g_clear_pointer(&instance_table, g_hash_table_destroy); /**************************************************************************
--- a/libpurple/util.c Mon Mar 20 23:06:42 2023 -0500
+++ b/libpurple/util.c Tue Mar 21 00:39:45 2023 -0500
@@ -541,8 +541,7 @@
purple_signal_emit_return_1(purple_get_core(), "uri-handler", proto, cmd, params);
- g_hash_table_destroy(params);
+ g_clear_pointer(¶ms, g_hash_table_destroy); --- a/pidgin/gtkblist.c Mon Mar 20 23:06:42 2023 -0500
+++ b/pidgin/gtkblist.c Tue Mar 21 00:39:45 2023 -0500
@@ -322,8 +322,7 @@
child = gtk_widget_get_first_child(GTK_WIDGET(data->rq_data.vbox));
- g_list_free(data->entries);
+ g_clear_list(&data->entries, NULL); if(!PURPLE_IS_PROTOCOL_CHAT(protocol)) {
--- a/pidgin/gtkrequest.c Mon Mar 20 23:06:42 2023 -0500
+++ b/pidgin/gtkrequest.c Tue Mar 21 00:39:45 2023 -0500
@@ -2290,6 +2290,5 @@
pidgin_request_uninit(void)
purple_signals_disconnect_by_handle(pidgin_request_get_handle());
- g_hash_table_destroy(datasheet_stock);
- datasheet_stock = NULL;
+ g_clear_pointer(&datasheet_stock, g_hash_table_destroy); --- a/pidgin/gtkutils.c Mon Mar 20 23:06:42 2023 -0500
+++ b/pidgin/gtkutils.c Tue Mar 21 00:39:45 2023 -0500
@@ -657,8 +657,7 @@
+ g_clear_list(&windows, NULL); gtk_window_set_transient_for(GTK_WINDOW(widget), parent);
--- a/pidgin/gtkxfer.c Mon Mar 20 23:06:42 2023 -0500
+++ b/pidgin/gtkxfer.c Tue Mar 21 00:39:45 2023 -0500
@@ -944,8 +944,7 @@
pidgin_xfers_uninit(void)
- if (xfer_dialog != NULL)
- pidgin_xfer_dialog_destroy(xfer_dialog);
+ g_clear_pointer(&xfer_dialog, pidgin_xfer_dialog_destroy); --- a/pidgin/plugins/disco/xmppdisco.c Mon Mar 20 23:06:42 2023 -0500
+++ b/pidgin/plugins/disco/xmppdisco.c Tue Mar 21 00:39:45 2023 -0500
@@ -711,8 +711,7 @@
xmpp_disco_unload(GPluginPlugin *plugin, G_GNUC_UNUSED gboolean unload,
G_GNUC_UNUSED GError **error)
- g_hash_table_destroy(iq_callbacks);
+ g_clear_pointer(&iq_callbacks, g_hash_table_destroy); purple_signals_disconnect_by_handle(plugin);
pidgin_disco_dialogs_destroy_all();
--- a/pidgin/plugins/gestures/stroke-draw.c Mon Mar 20 23:06:42 2023 -0500
+++ b/pidgin/plugins/gestures/stroke-draw.c Tue Mar 21 00:39:45 2023 -0500
@@ -319,9 +319,7 @@
struct gstroke_metrics *metrics;
GHashTable *hash_table = (GHashTable *)g_object_steal_data(G_OBJECT(widget),
- g_hash_table_destroy(hash_table);
+ g_clear_pointer(&hash_table, g_hash_table_destroy); metrics = (struct gstroke_metrics *)g_object_steal_data(G_OBJECT(widget),
--- a/pidgin/plugins/gestures/stroke.c Mon Mar 20 23:06:42 2023 -0500
+++ b/pidgin/plugins/gestures/stroke.c Tue Mar 21 00:39:45 2023 -0500
@@ -22,13 +22,9 @@
-_gstroke_init (struct gstroke_metrics *metrics)
- if (metrics->pointList != NULL) {
- g_slist_free_full(metrics->pointList, g_free);
- metrics->pointList = NULL;
- metrics->point_count = 0;
+_gstroke_init(struct gstroke_metrics *metrics) { + g_clear_slist(&metrics->pointList, g_free); + metrics->point_count = 0; /* figure out which bin the point falls in */