diff options
author | Thomas Haller <thaller@redhat.com> | 2018-05-07 16:23:57 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-05-11 10:59:18 +0200 |
commit | d74d566d85ccbd6d5db8d5a37f5cbe006412c595 (patch) | |
tree | a686068f91da7296df8a494a8c37796a55bd9f62 | |
parent | 62363ebc8fbe1caf537932a27a723772d2eb725b (diff) | |
download | NetworkManager-d74d566d85ccbd6d5db8d5a37f5cbe006412c595.tar.gz |
shared: add nm_auto_unref_gsource cleanup macro
-rw-r--r-- | shared/nm-utils/nm-macros-internal.h | 8 |
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 */ |