Git-commit:
c5a61e5a3c68144a421117916aef04f2c0fab84b
References: bsc#
1184574
The object_ref/unref methods are intended for use with any subclass of
the base Object. Using "Object *" in the signature is not adding any
meaningful level of type safety, since callers simply use "OBJECT(ptr)"
and this expands to an unchecked cast "(Object *)".
By using "void *" we enable the object_unref() method to be used to
provide support for g_autoptr() with any subclass.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <
20200723181410.
3145233-2-berrange@redhat.com>
Message-Id: <
20200831210740.126168-2-ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Lin Ma <lma@suse.com>
* Increase the reference count of a object. A object cannot be freed as long
* as its reference count is greater than zero.
*/
-void object_ref(Object *obj);
+void object_ref(void *obj);
/**
* object_unref:
* Decrease the reference count of a object. A object cannot be freed as long
* as its reference count is greater than zero.
*/
-void object_unref(Object *obj);
+void object_unref(void *obj);
/**
* object_property_add:
object_class_cmp);
}
-void object_ref(Object *obj)
+void object_ref(void *objptr)
{
+ Object *obj = OBJECT(objptr);
if (!obj) {
return;
}
atomic_inc(&obj->ref);
}
-void object_unref(Object *obj)
+void object_unref(void *objptr)
{
+ Object *obj = OBJECT(objptr);
if (!obj) {
return;
}