From 635214be97f49e55fb6333bf348512021072a519 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 12 Dec 2023 13:43:17 -0500 Subject: [PATCH] MT#55283 use g_auto for GOptionEntry Change-Id: I1eee92ebacaf3d3037a593b8603e9272f32c881d --- lib/auxlib.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/auxlib.c b/lib/auxlib.c index f7facee50..929ca5772 100644 --- a/lib/auxlib.c +++ b/lib/auxlib.c @@ -153,10 +153,7 @@ void config_load_free(struct rtpengine_common_config *cconfig) { g_free(cconfig->pidfile); } -static void free_gopte(GOptionEntry **k) { - if (k && *k) - free(*k); -} +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GOptionEntry, free) void config_load(int *argc, char ***argv, GOptionEntry *app_entries, const char *description, char *default_config, char *default_section, @@ -215,10 +212,10 @@ void config_load(int *argc, char ***argv, GOptionEntry *app_entries, const char unsigned int app_len = options_length(app_entries); size_t entries_size = sizeof(GOptionEntry) * (shared_len + app_len + 1); - AUTO_CLEANUP(GOptionEntry *entries, free_gopte) = malloc(entries_size); + g_autoptr(GOptionEntry) entries = malloc(entries_size); memcpy(entries, shared_options, sizeof(*entries) * shared_len); memcpy(&entries[shared_len], app_entries, sizeof(*entries) * (app_len + 1)); - AUTO_CLEANUP(GOptionEntry *entries_copy, free_gopte) = malloc(entries_size); + g_autoptr(GOptionEntry) entries_copy = malloc(entries_size); memcpy(entries_copy, entries, entries_size); c = g_option_context_new(description);