mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
qom: make object_delete usable for statically-allocated objects
Store in the object the freeing function that will be used at deletion time. This makes it possible to use object_delete on statically-allocated (embedded) objects. Dually, it makes it possible to use object_unparent and object_unref without leaking memory, when the lifetime of object might extend until after the call to object_delete. Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
667d22d1ae
commit
fde9bf4470
2 changed files with 13 additions and 1 deletions
|
@ -238,6 +238,14 @@ typedef struct ObjectProperty
|
|||
*/
|
||||
typedef void (ObjectUnparent)(Object *obj);
|
||||
|
||||
/**
|
||||
* ObjectFree:
|
||||
* @obj: the object being freed
|
||||
*
|
||||
* Called when an object's last reference is removed.
|
||||
*/
|
||||
typedef void (ObjectFree)(void *obj);
|
||||
|
||||
/**
|
||||
* ObjectClass:
|
||||
*
|
||||
|
@ -272,6 +280,7 @@ struct Object
|
|||
{
|
||||
/*< private >*/
|
||||
ObjectClass *class;
|
||||
ObjectFree *free;
|
||||
QTAILQ_HEAD(, ObjectProperty) properties;
|
||||
uint32_t ref;
|
||||
Object *parent;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue