summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-05-07 16:23:57 +0200
committerThomas Haller <thaller@redhat.com>2018-05-11 10:59:18 +0200
commitd74d566d85ccbd6d5db8d5a37f5cbe006412c595 (patch)
treea686068f91da7296df8a494a8c37796a55bd9f62
parent62363ebc8fbe1caf537932a27a723772d2eb725b (diff)
downloadNetworkManager-d74d566d85ccbd6d5db8d5a37f5cbe006412c595.tar.gz
shared: add nm_auto_unref_gsource cleanup macro
-rw-r--r--shared/nm-utils/nm-macros-internal.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h
index bd375a35a9..72c1f807af 100644
--- a/shared/nm-utils/nm-macros-internal.h
+++ b/shared/nm-utils/nm-macros-internal.h
@@ -153,6 +153,14 @@ _nm_auto_protect_errno (int *p_saved_errno)
}
#define NM_AUTO_PROTECT_ERRNO(errsv_saved) nm_auto(_nm_auto_protect_errno) _nm_unused const int errsv_saved = (errno)
+static inline void
+_nm_auto_unref_gsource (GSource **ptr)
+{
+ if (*ptr)
+ g_source_unref (g_steal_pointer (ptr));
+}
+#define nm_auto_unref_gsource nm_auto(_nm_auto_unref_gsource)
+
/*****************************************************************************/
/* http://stackoverflow.com/a/11172679 */