summaryrefslogtreecommitdiff
path: root/shared/nm-utils
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 16:51:20 +0200
commit286db5049ea2e9494747dfab595a97cd19c85452 (patch)
treeed41fbc107717d30d4f5c9657347bf6b1d15a7ca /shared/nm-utils
parentfe3db7aed38b0a50d2b0e84e0fecc23a23a08738 (diff)
downloadNetworkManager-286db5049ea2e9494747dfab595a97cd19c85452.tar.gz
shared: add nm_auto_unref_gsource cleanup macro
Diffstat (limited to 'shared/nm-utils')
-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 */