diff options
author | Paolo Bonzini | 2012-11-23 09:47:14 +0100 |
---|---|---|
committer | Anthony Liguori | 2012-11-26 20:41:00 +0100 |
commit | fde9bf4470d4a3b6ee1da0dee2370ab028b6314a (patch) | |
tree | 7bf9d19324d25310090bd09b28cb3683cadc2251 /include | |
parent | qdev: move bus removal to object_unparent (diff) | |
download | qemu-fde9bf4470d4a3b6ee1da0dee2370ab028b6314a.tar.gz qemu-fde9bf4470d4a3b6ee1da0dee2370ab028b6314a.tar.xz qemu-fde9bf4470d4a3b6ee1da0dee2370ab028b6314a.zip |
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/object.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/qemu/object.h b/include/qemu/object.h index 232463b3c7..5ddcb4aa5f 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -239,6 +239,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: * * The base for all classes. The only thing that #ObjectClass contains is an @@ -272,6 +280,7 @@ struct Object { /*< private >*/ ObjectClass *class; + ObjectFree *free; QTAILQ_HEAD(, ObjectProperty) properties; uint32_t ref; Object *parent; |