platform: add nmp_object_ref_set() helper

This commit is contained in:
Thomas Haller 2020-07-21 17:48:30 +02:00
parent 04be1dbd80
commit d4b7a3c27e
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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);