Browse Source

MT#55283 use g_auto for GOptionEntry

Change-Id: I1eee92ebacaf3d3037a593b8603e9272f32c881d
pull/1776/head
Richard Fuchs 2 years ago
parent
commit
635214be97
1 changed files with 3 additions and 6 deletions
  1. +3
    -6
      lib/auxlib.c

+ 3
- 6
lib/auxlib.c View File

@ -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);


Loading…
Cancel
Save