diff options
author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2023-03-21 00:39:45 -0500 |
---|---|---|
committer | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2023-03-21 00:39:45 -0500 |
commit | 1b4f76976e1a069831b98518588f587be79b122c (patch) | |
tree | 0558873858c1d4b3fb27069c4932d729e3a7f397 /finch | |
parent | ae674f38b973f59afa38f5fbcb8b4c069188e59f (diff) | |
download | pidgin-1b4f76976e1a069831b98518588f587be79b122c.tar.gz |
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/
Diffstat (limited to 'finch')
-rw-r--r-- | finch/gntaccount.c | 12 | ||||
-rw-r--r-- | finch/gntblist.c | 6 | ||||
-rw-r--r-- | finch/gntconn.c | 2 | ||||
-rw-r--r-- | finch/gntnotify.c | 7 | ||||
-rw-r--r-- | finch/gntprefs.c | 3 | ||||
-rw-r--r-- | finch/plugins/gnttinyurl/gnttinyurl.c | 3 | ||||
-rw-r--r-- | finch/plugins/grouping/grouping.c | 3 |
7 files changed, 11 insertions, 25 deletions
diff --git a/finch/gntaccount.c b/finch/gntaccount.c index 1baf2079f8..89134297b2 100644 --- a/finch/gntaccount.c +++ b/finch/gntaccount.c @@ -380,11 +380,7 @@ add_account_options(AccountEditDialog *dialog) 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_init(void) } void -finch_accounts_uninit(void) -{ - if (accounts.window) - gnt_widget_destroy(accounts.window); +finch_accounts_uninit(void) { + g_clear_pointer(&accounts.window, gnt_widget_destroy); } diff --git a/finch/gntblist.c b/finch/gntblist.c index 9af27689bb..d21e7846bb 100644 --- a/finch/gntblist.c +++ b/finch/gntblist.c @@ -1844,13 +1844,11 @@ reset_blist_window(G_GNUC_UNUSED GntWidget *window, if (ggblist->typing) g_source_remove(ggblist->typing); remove_peripherals(ggblist); - if (ggblist->tagged) - 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); ggblist = NULL; } diff --git a/finch/gntconn.c b/finch/gntconn.c index 0f5e1535c0..a521ed646e 100644 --- a/finch/gntconn.c +++ b/finch/gntconn.c @@ -145,5 +145,5 @@ finch_connections_uninit(void) 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); } diff --git a/finch/gntnotify.c b/finch/gntnotify.c index 20e435eb83..797f9caf1a 100644 --- a/finch/gntnotify.c +++ b/finch/gntnotify.c @@ -424,9 +424,6 @@ finch_notify_init(void) } void -finch_notify_uninit(void) -{ - g_hash_table_destroy(userinfo); +finch_notify_uninit(void) { + g_clear_pointer(&userinfo, g_hash_table_destroy); } - - diff --git a/finch/gntprefs.c b/finch/gntprefs.c index 5e90070d73..1525bb2fed 100644 --- a/finch/gntprefs.c +++ b/finch/gntprefs.c @@ -229,8 +229,7 @@ static Prefs credentials[] = static void free_strings(void) { - 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; } diff --git a/finch/plugins/gnttinyurl/gnttinyurl.c b/finch/plugins/gnttinyurl/gnttinyurl.c index be54530fb8..da5535c005 100644 --- a/finch/plugins/gnttinyurl/gnttinyurl.c +++ b/finch/plugins/gnttinyurl/gnttinyurl.c @@ -552,8 +552,7 @@ tiny_url_unload(GPluginPlugin *plugin, G_GNUC_UNUSED gboolean shutdown, soup_session_abort(session); g_clear_object(&session); - g_hash_table_destroy(tinyurl_cache); - tinyurl_cache = NULL; + g_clear_pointer(&tinyurl_cache, g_hash_table_destroy); return TRUE; } diff --git a/finch/plugins/grouping/grouping.c b/finch/plugins/grouping/grouping.c index a09a4ed9a3..a7abacc43a 100644 --- a/finch/plugins/grouping/grouping.c +++ b/finch/plugins/grouping/grouping.c @@ -250,8 +250,7 @@ nested_group_init(void) static gboolean nested_group_uninit(void) { - g_hash_table_destroy(groups); - groups = NULL; + g_clear_pointer(&groups, g_hash_table_destroy); return TRUE; } |