summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-08-30 19:15:39 +0200
committerThomas Haller <thaller@redhat.com>2017-09-08 11:05:04 +0200
commit6801cd65bf5b429d7295f335605742b92642c508 (patch)
treef6c0f89d936167ea1cf7353fdc6dbced15507ac9
parenta0ca6070806cd62e90ae0660c4c3652606e0fbcf (diff)
platform: add nm_clear_nmp_object() util
-rw-r--r--src/platform/nmp-object.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/platform/nmp-object.h b/src/platform/nmp-object.h
index 6b4a28c25..6aeb1fb1b 100644
--- a/src/platform/nmp-object.h
+++ b/src/platform/nmp-object.h
@@ -435,6 +435,21 @@ nmp_object_unref (const NMPObject *obj)
return NULL;
}
+#define nm_clear_nmp_object(ptr) \
+ ({ \
+ typeof (ptr) _ptr = (ptr); \
+ typeof (*_ptr) _pptr; \
+ gboolean _changed = FALSE; \
+ \
+ if ( _ptr \
+ && (_pptr = *_ptr)) { \
+ *_ptr = NULL; \
+ nmp_object_unref (_pptr); \
+ _changed = TRUE; \
+ } \
+ _changed; \
+ })
+
NMPObject *nmp_object_new (NMPObjectType obj_type, const NMPlatformObject *plob);
NMPObject *nmp_object_new_link (int ifindex);