Skip to content
  • Anthony Liguori's avatar
    object: sure up reference counting · db85b575
    Anthony Liguori authored
    
    
    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.
    
    Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
    db85b575