From nobody Wed Nov 27 07:28:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552623902784851.3777320223625; Thu, 14 Mar 2019 21:25:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6CEE9307ACF6; Fri, 15 Mar 2019 04:24:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4AE05D73F; Fri, 15 Mar 2019 04:24:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 93B1541F3D; Fri, 15 Mar 2019 04:24:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2F4OoZg005434 for ; Fri, 15 Mar 2019 00:24:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 967EB19C5A; Fri, 15 Mar 2019 04:24:50 +0000 (UTC) Received: from blue.redhat.com (ovpn-118-35.phx2.redhat.com [10.3.118.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A68219C56; Fri, 15 Mar 2019 04:24:48 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Thu, 14 Mar 2019 23:24:47 -0500 Message-Id: <20190315042447.32385-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] virobject: Improve documentation X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 15 Mar 2019 04:25:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" I had to inspect the code to learn whether a final virObjectUnref() calls ALL dispose callbacks in child-to-parent order (akin to C++ destructors), or whether I manually had to call a parent-class dispose when writing a child class dispose method. The answer is the former. (Thankfully, since VIR_FREE wipes out pointers for safety, even if I had guessed wrong, I probably would not have tripped over a double-free fault when the parent dispose ran for the second time). While at it, the VIR_CLASS_NEW macro requires that the virObject component at offset 0 be reached through the name 'parent', not 'object'. Signed-off-by: Eric Blake Reviewed-by: Erik Skultety --- src/util/virobject.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/util/virobject.c b/src/util/virobject.c index f08c18ce44..462b3d7d3f 100644 --- a/src/util/virobject.c +++ b/src/util/virobject.c @@ -147,10 +147,11 @@ virClassForObjectRWLockable(void) * * Register a new object class with @name. The @objectSize * should give the total size of the object struct, which - * is expected to have a 'virObject object;' field as its - * first member. When the last reference on the object is - * released, the @dispose callback will be invoked to free - * memory of the object fields + * is expected to have a 'virObject parent;' field as (or + * contained in) its first member. When the last reference + * on the object is released, the @dispose callback will be + * invoked to free memory of the local object fields, as + * well as dispose callbacks of the parent classes * * Returns a new class instance */ --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list