diff options
-rw-r--r-- | shared/nm-glib-aux/nm-macros-internal.h | 8 | ||||
-rw-r--r-- | src/initrd/nm-initrd-generator.c | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/shared/nm-glib-aux/nm-macros-internal.h b/shared/nm-glib-aux/nm-macros-internal.h index 9502c442ec..e36e7af7fe 100644 --- a/shared/nm-glib-aux/nm-macros-internal.h +++ b/shared/nm-glib-aux/nm-macros-internal.h @@ -231,6 +231,14 @@ NM_AUTO_DEFINE_FCN0 (GError *, gs_local_free_error, g_error_free) #define gs_unref_keyfile nm_auto(gs_local_keyfile_unref) NM_AUTO_DEFINE_FCN0 (GKeyFile *, gs_local_keyfile_unref, g_key_file_unref) +/** + * gs_free_option_context: + * + * Call g_option_context_free() on a variable location when it goes out of scope. + */ +#define gs_free_option_context nm_auto(gs_local_option_context) +NM_AUTO_DEFINE_FCN0 (GOptionContext *, gs_local_option_context, g_option_context_free); + /*****************************************************************************/ #include "nm-glib.h" diff --git a/src/initrd/nm-initrd-generator.c b/src/initrd/nm-initrd-generator.c index 0ff3428e28..4603813013 100644 --- a/src/initrd/nm-initrd-generator.c +++ b/src/initrd/nm-initrd-generator.c @@ -90,7 +90,7 @@ main (int argc, char *argv[]) { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL, NULL }, { NULL } }; - GOptionContext *option_context; + gs_free_option_context GOptionContext *option_context = NULL; GError *error = NULL; int errsv; |