mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 09:50:09 +01:00
platform: add nmp_object_ref_set() helper
This commit is contained in:
parent
04be1dbd80
commit
d4b7a3c27e
1 changed files with 19 additions and 0 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue