From nobody Mon Feb 9 20:34:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579794448; cv=none; d=zohomail.com; s=zohoarc; b=On6pBLcuQLHumtSH0n2pr0rc4ytygE9vUKoTFA+YkDV0cL++VvA82DgI6Wjolj1QNiYScpRMCiu459RL8+DdBt52LCw+BpuMNnx2IPaUOIQQSr67vGdgn8hV2ds1H5+NjJ+GiErYmNhR4Kj4S+0DkhQhGphHHZJacS2j/9xJiH0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579794448; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6W21RtF4MhsJPffhnX5gfH1aakhUYnRTEcxuzNxGkrI=; b=elybKZSrnx1t+nQPmjNwveN4Z8dxjzkk1pFs0dvSQ7dGrwDER8UXsbactaYVWEyfDxxK75QgUZeA62UeG+1LRgyBMxZShvqhxBlU3Mi3BeVt/Q+a4mycCO6ZoShJ6v9pTfPrSgZhVLxFNesF0ZB6JQXKjLzYX+JwxTCFRRfdJeo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579794448048892.4808391504722; Thu, 23 Jan 2020 07:47:28 -0800 (PST) Received: from localhost ([::1]:59710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iueha-0004Ic-6K for importer@patchew.org; Thu, 23 Jan 2020 10:47:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51885) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iucrl-0005ZT-Vk for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:49:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iucrk-0004SN-Ua for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:49:49 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:40809) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iucrk-0004Qs-O5 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:49:48 -0500 Received: by mail-wm1-x329.google.com with SMTP id t14so2595748wmi.5 for ; Thu, 23 Jan 2020 05:49:48 -0800 (PST) Received: from 640k.localdomain.com ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s15sm3073171wrp.4.2020.01.23.05.49.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jan 2020 05:49:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6W21RtF4MhsJPffhnX5gfH1aakhUYnRTEcxuzNxGkrI=; b=Bvqam1BTeYAY8Q9IFxflI6GOooT7M8E4BXoPA6YiaS2i/bdUjm0fA4VFVMwTvCAt52 XVkIRVKgsSe/hUGguukjLKuJk4H6wfl+rFBRRaRtVhgXuIYqOxfJkPFYHk6nHIlvgXLl XDGJ55R6zaHSIqQpJK1uO5aeLjXtYT0bfMmbPxVCRhbMVZVccl+QRfKhGp4ec1ZYWzsE ORh/i7TqtLqPlgZvMKDs0ZEa+0bOrnhD0oqlNA5donLXQxrmb6VPs1oAvmAdX3suf4Hm BTL2UmYjlkKSB1JK8725h6thrhK/wQ3N7527AjVjttoutcl/WU2XhSARu1F5eN5MEiRv hUgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=6W21RtF4MhsJPffhnX5gfH1aakhUYnRTEcxuzNxGkrI=; b=LT0f6uOUmV0pibkLXJXJ18R3z8mMWIx89rqGqOtxOfl/5ERAQSFwDjfoT+Vme8GW80 gZGGs6/1oj1DymY6xgBSoaX/3fMrFB0EfMwPltalPU33xWqB95HIV7GDPlYX51fjtP9I MQ8guDLGTCL9sckGcFwCPOUcuzNEt08VX1N8RYsF2QmOYpw42rtcNzBj69Dpn+ejNrvK X4A24ul75w6/6IF6pSbrZgHO6c8XuinA9osLyxNvgqP9dcVfLXZ1P1YRGFplMatsmqss tRUTBYP+Va4UnA3gEaJrXSVkYCfFC+sFSwaWX2Oex3McwX6Sqdum9pu2zvT9Zjz7E0R9 H/1A== X-Gm-Message-State: APjAAAULBq86ieOYJj5ytkLLURiUn4zb+zv2v81CveYZUKlj4Lxdbp2K PvVnopU6tshNpr4iNUAszByU7ra0 X-Google-Smtp-Source: APXvYqynm/nCI1LJsNISgpTFGkd7OSMtzbSQRhDwbypMjZ7B5LgP/HpWDXTPDk+3id5qJOoYvE7O4g== X-Received: by 2002:a1c:9602:: with SMTP id y2mr4284529wmd.23.1579787387607; Thu, 23 Jan 2020 05:49:47 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 47/59] object: release all props Date: Thu, 23 Jan 2020 14:48:50 +0100 Message-Id: <1579787342-27146-48-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1579787342-27146-1-git-send-email-pbonzini@redhat.com> References: <1579787342-27146-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau Class properties may have to release resources when the object is destroyed. Let's use the existing release() callback for that, but class properties must not release ObjectProperty, as it can be shared by various instances. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20200110153039.1379601-18-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- qom/object.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/qom/object.c b/qom/object.c index 202d576..84d234d 100644 --- a/qom/object.c +++ b/qom/object.c @@ -592,23 +592,22 @@ static inline bool object_property_is_child(ObjectPro= perty *prop) =20 static void object_property_del_all(Object *obj) { + g_autoptr(GHashTable) done =3D g_hash_table_new(NULL, NULL); ObjectProperty *prop; - GHashTableIter iter; - gpointer key, value; + ObjectPropertyIterator iter; bool released; =20 do { released =3D false; - g_hash_table_iter_init(&iter, obj->properties); - while (g_hash_table_iter_next(&iter, &key, &value)) { - prop =3D value; - if (prop->release) { - prop->release(obj, prop->name, prop->opaque); - prop->release =3D NULL; - released =3D true; - break; + object_property_iter_init(&iter, obj); + while ((prop =3D object_property_iter_next(&iter)) !=3D NULL) { + if (g_hash_table_add(done, prop)) { + if (prop->release) { + prop->release(obj, prop->name, prop->opaque); + released =3D true; + break; + } } - g_hash_table_iter_remove(&iter); } } while (released); =20 --=20 1.8.3.1