From 46e6477f889119b2d1e8891bdba5e95c87dd0534 Mon Sep 17 00:00:00 2001 From: Richard Cohen Date: Wed, 21 Jun 2023 10:35:22 +0100 Subject: [PATCH] Refactor: use common code to free the list of guids --- libgnucash/engine/test-core/test-engine-stuff.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/libgnucash/engine/test-core/test-engine-stuff.cpp b/libgnucash/engine/test-core/test-engine-stuff.cpp index cc43a2f3ef..076b4aba0e 100644 --- a/libgnucash/engine/test-core/test-engine-stuff.cpp +++ b/libgnucash/engine/test-core/test-engine-stuff.cpp @@ -1497,14 +1497,9 @@ get_random_guids(int max) } static void -free_random_guids(GList *guids) +free_guids(GList *guids) { - GList *node; - - for (node = guids; node; node = node->next) - guid_free (static_cast(node->data)); - - g_list_free (guids); + g_list_free_full (guids, (GDestroyNotify)guid_free); } static QofQueryOp @@ -1671,7 +1666,7 @@ get_random_query(void) guids, compare_param(QOF_GUID_MATCH_NONE), get_random_queryop ()); - free_random_guids (guids); + free_guids (guids); break; case 2: /*PR_ACTION */ @@ -2026,9 +2021,7 @@ make_trans_query (Transaction *trans, TestQueryTypes query_types) } xaccQueryAddAccountGUIDMatch (q, list, QOF_GUID_MATCH_ANY, QOF_QUERY_AND); - for (node = list; node; node = node->next) - guid_free (static_cast(node->data)); - g_list_free (list); + free_guids (list); } if (query_types & GUID_QT)