From f4941a5b01939aad152a36dc8deb6ef0a031ad9e Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sat, 9 Oct 2021 10:24:45 +0800 Subject: [PATCH] use g_list_free_full --- bindings/guile/gnc-engine-guile.c | 9 ++------- gnucash/gnome/dialog-tax-info.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/bindings/guile/gnc-engine-guile.c b/bindings/guile/gnc-engine-guile.c index 45a69ec243..3873e0ea38 100644 --- a/bindings/guile/gnc-engine-guile.c +++ b/bindings/guile/gnc-engine-guile.c @@ -331,15 +331,10 @@ gnc_scm2guid_glist (SCM guids_scm) return g_list_reverse (guids); } -static void +static inline void gnc_guid_glist_free (GList *guids) { - GList *node; - - for (node = guids; node; node = node->next) - guid_free (node->data); - - g_list_free (guids); + g_list_free_full (guids, guid_free); } static SCM diff --git a/gnucash/gnome/dialog-tax-info.c b/gnucash/gnome/dialog-tax-info.c index fcd0a3dc7d..6b342adf93 100644 --- a/gnucash/gnome/dialog-tax-info.c +++ b/gnucash/gnome/dialog-tax-info.c @@ -168,7 +168,7 @@ initialize_getters (void) } static void -destroy_tax_type_info (gpointer data, gpointer user_data) +destroy_tax_type_info (gpointer data) { TaxTypeInfo *tax_type = data; @@ -187,15 +187,14 @@ destroy_tax_type_info (gpointer data, gpointer user_data) g_free (tax_type); } -static void +static inline void destroy_tax_type_infos (GList *types) { - g_list_foreach (types, destroy_tax_type_info, NULL); - g_list_free (types); + g_list_free_full (types, destroy_tax_type_info); } static void -destroy_txf_info (gpointer data, gpointer user_data) +destroy_txf_info (gpointer data) { TXFInfo *txf_info = data; @@ -217,11 +216,10 @@ destroy_txf_info (gpointer data, gpointer user_data) g_free (txf_info); } -static void +static inline void destroy_txf_infos (GList *infos) { - g_list_foreach (infos, destroy_txf_info, NULL); - g_list_free (infos); + g_list_free_full (infos, destroy_txf_info); } static void