From 47a1a56f16cdd60a1e66f9160cb33bcb4c6b1b87 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sun, 11 Feb 2024 23:07:53 +0800 Subject: [PATCH] [gnc-commodity.cpp] fq_version is a std::string thus can free itself on exit --- libgnucash/engine/gnc-commodity.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/libgnucash/engine/gnc-commodity.cpp b/libgnucash/engine/gnc-commodity.cpp index c952bea489..f092703f82 100644 --- a/libgnucash/engine/gnc-commodity.cpp +++ b/libgnucash/engine/gnc-commodity.cpp @@ -146,7 +146,7 @@ struct gnc_new_iso_code #define GNC_NEW_ISO_CODES \ (sizeof(gnc_new_iso_codes) / sizeof(struct gnc_new_iso_code)) -static char *fq_version = NULL; +static std::string fq_version; struct gnc_quote_source_s { @@ -278,7 +278,7 @@ static GList *new_quote_sources = NULL; gboolean gnc_quote_source_fq_installed (void) { - return (fq_version != NULL); + return (!fq_version.empty()); } @@ -291,7 +291,7 @@ gnc_quote_source_fq_installed (void) const char* gnc_quote_source_fq_version (void) { - return fq_version; + return fq_version.c_str(); } /******************************************************************** @@ -548,14 +548,10 @@ gnc_quote_source_set_fq_installed (const char* version_string, if (!sources_list) return; - if (fq_version) - { - g_free (fq_version); - fq_version = NULL; - } - if (version_string) - fq_version = g_strdup (version_string); + fq_version = version_string; + else + fq_version.clear(); for (node = sources_list; node; node = node->next) {