[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1.3 3/5] qom: make object_delete usable for stat
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 1.3 3/5] qom: make object_delete usable for statically-allocated objects |
Date: |
Fri, 23 Nov 2012 18:10:07 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1 |
Il 23/11/2012 18:02, Andreas Färber ha scritto:
>> 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.
>> >
>> > Signed-off-by: Paolo Bonzini <address@hidden>
> The code is
>
> Reviewed-by: Andreas Färber <address@hidden>
>
> however I do not agree with the goal in the subject. I thought this was
> to match C++ in actually deallocating the memory.
At the "real" end of the series object_delete disappears completely. I
posted only the initial part because the rest is not appropriate for
1.3, you can see it at https://github.com/bonzini/qemu/commits/qdev-free.
You just have ref/unref to keep an object alive, and unparent to remove it.
qbus_free and qdev_free become simply synonyms for object_unparent.
After the unparent, the refcount is magically zero for the bus/device
and everything below it in the qtree, and they disappear.
Paolo
- Re: [Qemu-devel] [PATCH 1.3 4/5] qdev: simplify (de)allocation of buses, (continued)
- [Qemu-devel] [PATCH 1.3 2/5] qdev: move bus removal to object_unparent, Paolo Bonzini, 2012/11/23
- [Qemu-devel] [PATCH 1.3 1/5] qom: fix refcount of non-heap-allocated objects, Paolo Bonzini, 2012/11/23
- [Qemu-devel] [PATCH 1.3 3/5] qom: make object_delete usable for statically-allocated objects, Paolo Bonzini, 2012/11/23
- [Qemu-devel] [PATCH 1.3 5/5] qom: make object_finalize static, Paolo Bonzini, 2012/11/23
- Re: [Qemu-devel] [PATCH 1.3 0/5] QOM/qdev lifetime fixes, Anthony Liguori, 2012/11/26