On 01/30/2012 10:08 PM, Anthony Liguori wrote:
Now we have the following behavior:

1) object_new() returns an object with ref = 1
2) object_initialize() does not increase the reference count (ref may be 0).
3) object_deref() will finalize the object when ref = 0.  it does not free the
    memory associated with the object.
4) both link and child properties correctly set the reference count.

The expected usage is the following:

1) child devices should generally be created via object_initialize() using
    memory from the parent device.  Adding the object as a child property will
    take ownership of the object and tie the child's life cycle to the parent.

2) If a child device is created via qdev_create() or some other form of
    object_new(), there must be an object_delete() call in the parent device's
    finalize function.

We might want to fix this by adding a special "created as child" refcount value, so that the object_delete can still be automatic. Adding floating references as they have them in GObject is also possible. I agree that it can be left for later, though.

Paolo

Reply via email to