summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-07-21 17:48:30 +0200
committerThomas Haller <thaller@redhat.com>2020-07-23 15:29:24 +0200
commitd4b7a3c27eeabb2cc220de84997436cc078edd62 (patch)
tree72fe813ed6bcb6c6b60df3d2e9b66691f1d1cdd9
parent04be1dbd80e068199c9cb579d620ed53b36d0bd1 (diff)
downloadNetworkManager-d4b7a3c27eeabb2cc220de84997436cc078edd62.tar.gz
platform: add nmp_object_ref_set() helper
-rw-r--r--src/platform/nmp-object.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/platform/nmp-object.h b/src/platform/nmp-object.h
index f83f27d7f8..cef25ea79b 100644
--- a/src/platform/nmp-object.h
+++ b/src/platform/nmp-object.h
@@ -614,6 +614,25 @@ nmp_object_unref (const NMPObject *obj)
_changed; \
})
+static inline gboolean
+nmp_object_ref_set (const NMPObject **pp, const NMPObject *obj)
+{
+ gboolean _changed = FALSE;
+ const NMPObject *p;
+
+ nm_assert (!pp || !*pp || NMP_OBJECT_IS_VALID (*pp));
+ nm_assert (!obj || NMP_OBJECT_IS_VALID (obj));
+
+ if ( pp
+ && ((p = *pp) != obj)) {
+ nmp_object_ref (obj);
+ *pp = obj;
+ nmp_object_unref (p);
+ _changed = TRUE;
+ }
+ return _changed;
+}
+
NMPObject *nmp_object_new (NMPObjectType obj_type, gconstpointer plobj);
NMPObject *nmp_object_new_link (int ifindex);