Just do nothing if passed NULL for a ref or unref. This avoids
call sites that manage a combination of NULL or non-NULL pointers
having to add iffery around every ref and unref.
Signed-off-by: Peter Crosthwaite <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
void object_ref(Object *obj)
{
+ if (!obj) {
+ return;
+ }
atomic_inc(&obj->ref);
}
void object_unref(Object *obj)
{
+ if (!obj) {
+ return;
+ }
g_assert(obj->ref > 0);
/* parent always holds a reference to its children */
return;
}
- if (new_target) {
- object_ref(new_target);
- }
+ object_ref(new_target);
*child = new_target;
- if (old_target != NULL) {
- object_unref(old_target);
- }
+ object_unref(old_target);
}
static Object *object_resolve_link_property(Object *parent, void *opaque, const gchar *part)