summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-05-10 20:43:51 +0200
committerThomas Haller <thaller@redhat.com>2021-05-14 11:41:32 +0200
commit8a11380e80e27139f5949bc1e8fbffbdab75003a (patch)
tree77b1cec2a7aef7ed3c1de6b432d4e0e58e89f02a
parent071ef784cfb05abbda6c811000ed4cd93026e6a9 (diff)
downloadNetworkManager-8a11380e80e27139f5949bc1e8fbffbdab75003a.tar.gz
glib-aux: add nm_auto_pop_and_unref_gmaincontext cleanup macro
-rw-r--r--src/libnm-glib-aux/nm-shared-utils.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h
index 4d0fa8522a..7bd3845a56 100644
--- a/src/libnm-glib-aux/nm-shared-utils.h
+++ b/src/libnm-glib-aux/nm-shared-utils.h
@@ -1564,6 +1564,18 @@ NM_AUTO_DEFINE_FCN0(GSource *, _nm_auto_destroy_and_unref_gsource, nm_g_source_d
NM_AUTO_DEFINE_FCN0(GMainContext *, _nm_auto_pop_gmaincontext, g_main_context_pop_thread_default);
#define nm_auto_pop_gmaincontext nm_auto(_nm_auto_pop_gmaincontext)
+static inline void
+nm_g_main_context_pop_and_unref(GMainContext *context)
+{
+ g_main_context_pop_thread_default(context);
+ g_main_context_unref(context);
+}
+
+NM_AUTO_DEFINE_FCN0(GMainContext *,
+ _nm_auto_pop_and_unref_gmaincontext,
+ nm_g_main_context_pop_and_unref);
+#define nm_auto_pop_and_unref_gmaincontext nm_auto(_nm_auto_pop_and_unref_gmaincontext)
+
static inline gboolean
nm_source_func_unref_gobject(gpointer user_data)
{