From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tbx7L-0006I7-Vw for qemu-devel@nongnu.org; Fri, 23 Nov 2012 12:32:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tbx7G-0006HA-73 for qemu-devel@nongnu.org; Fri, 23 Nov 2012 12:32:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tbx7F-0006Go-W0 for qemu-devel@nongnu.org; Fri, 23 Nov 2012 12:32:38 -0500 Message-ID: <50AFADEF.6000905@redhat.com> Date: Fri, 23 Nov 2012 18:10:07 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1353660436-8897-1-git-send-email-pbonzini@redhat.com> <1353660436-8897-4-git-send-email-pbonzini@redhat.com> <50AFAC11.1050500@suse.de> In-Reply-To: <50AFAC11.1050500@suse.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1.3 3/5] qom: make object_delete usable for statically-allocated objects List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?ISO-8859-15?Q?Andreas_F=E4rber?= Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, qemu-devel@nongnu.org, Liu Ping Fan Il 23/11/2012 18:02, Andreas F=E4rber 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-all= ocated >> > (embedded) objects. Dually, it makes it possible to use object_unpa= rent >> > and object_unref without leaking memory, when the lifetime of object >> > might extend until after the call to object_delete. >> >=20 >> > Signed-off-by: Paolo Bonzini > The code is >=20 > Reviewed-by: Andreas F=E4rber >=20 > 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 i= t. 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