From nobody Fri Dec 19 20:15:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1587477034; cv=none; d=zohomail.com; s=zohoarc; b=NdGpfvKrIkrKk8M3WiC3s1kKKcsuBMR4TErBCOer+aydbOU8ywLveBeIUIftn8PX3lbqSqPiMqmte/WMZSbshfsNOdipipcHhtbbE1x7RS/NOvNYZ2fn0RKFafSexwWmTZyu01YOVKJ2IXsKiGE5+C9TEYV2JWjZMtdGFtq2tFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587477034; 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=IfDxAU4M6t6JE1wAVtfF8pmPsC8Md21j/LrhUEA+jUQ=; b=Bum0zQn5Ql49SCGtfF0yMGPpGfMLAQbgZKEpO4pGOOJmPeo26h4YqfXiaCVwsWLMS6RaTqbzzURZ3L37AAh55+SBAA2wg9Dm8jhyjlXie//rGgYcybmwvZpIBGchnLK2rTvVYY7R1R2O8oWRVeJx35flfiSc3dcbi34ENzpoIng= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1587477033998401.6905468451208; Tue, 21 Apr 2020 06:50:33 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-485-VHt8jDeeMLemNIUs4uOwzA-1; Tue, 21 Apr 2020 09:50:18 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 846E5107ACC7; Tue, 21 Apr 2020 13:50:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2FCF819925; Tue, 21 Apr 2020 13:50:13 +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 B032418089CD; Tue, 21 Apr 2020 13:50:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03LDo94K003253 for ; Tue, 21 Apr 2020 09:50:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C92211921A3; Tue, 21 Apr 2020 13:50:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 565C011921A5 for ; Tue, 21 Apr 2020 13:50:05 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F891185A78E for ; Tue, 21 Apr 2020 13:50:05 +0000 (UTC) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-451-50zO7brBNEe88po1nXR1cg-1; Tue, 21 Apr 2020 09:50:03 -0400 Received: by mail-wr1-f48.google.com with SMTP id s10so7411528wrr.0 for ; Tue, 21 Apr 2020 06:50:02 -0700 (PDT) Received: from localhost.localdomain (public-gprs377075.centertel.pl. [37.47.104.52]) by smtp.gmail.com with ESMTPSA id q10sm3981826wrv.95.2020.04.21.06.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587477032; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=IfDxAU4M6t6JE1wAVtfF8pmPsC8Md21j/LrhUEA+jUQ=; b=SJmmmz/a/pYLOYUy8DrWivWTgrTObNLftnLOIhTSsZHUqe4zdBsmx6Di+1/1WS0T8NmGWc c0EqP+nP44e2Dv+XNdn8IyNj4PIDzLuHXuLCNX3sCASOWbww3c4MQdKDfK1FHi5yDTfrrm U+iLCzzn7Ejlk9XJ6KiLSKUnfd+lg1A= X-MC-Unique: VHt8jDeeMLemNIUs4uOwzA-1 X-MC-Unique: 50zO7brBNEe88po1nXR1cg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gh/i1jHHCJqfRy3yQ8hxEOAl+9xgIkk9ve1w1Lc8m9A=; b=ne8sbBLuOU+QkdTeCRQjAgU5mrD+SekZjwWB/kEgqCgvTqWwvWPCGIA5Tv8raCNF1A dE4LhwJVPaplNtnA5caN/m37dLQFKMfLf/PDZV70RWu+twEv7FkRD9wnCDkokfKxK/1f lFmv7ENB6a5aTRFcpA6vX8g2Lqb1IxyDT0wZhmURcnyhD+6MUV6+lmRSNtoD6JFy1ISf A0i3XJz2+NKF6FE6dl2CRBIMupI055Ylc3yICQEP4lang1UL9w0tEzqMs1mwyQcma6us XcWhqQu+JhY3Dc+XGftFVEmNv+jI5gyZGE3ol3vfRcV04KMS0qr9E6NNlWN/QvEVYyoP 9w1Q== X-Gm-Message-State: AGi0Puab+YWz+ajDRJouMQKkGnzxRFZmPBJL0UYfO+8RjRFFNDw2mb7b Hpcrcd4eVx/f+R2ypdqiiIPHGtmE4y8= X-Google-Smtp-Source: APiQypLCYpZsV6cHrfPJQE808Q3lr54uLUdKXPUY7gqgQcbfdhZz1sYyYhKQJc5eUVNfpj7F/gxeaA== X-Received: by 2002:adf:f98e:: with SMTP id f14mr23978034wrr.253.1587477001621; Tue, 21 Apr 2020 06:50:01 -0700 (PDT) From: Rafael Fonseca To: libvir-list@redhat.com Subject: [PATCH v2 04/40] util: add function to unref array of GObjects Date: Tue, 21 Apr 2020 15:48:45 +0200 Message-Id: <20200421134921.3717019-5-r4f4rfs@gmail.com> In-Reply-To: <20200421134921.3717019-1-r4f4rfs@gmail.com> References: <20200421134921.3717019-1-r4f4rfs@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 03LDo94K003253 X-loop: libvir-list@redhat.com Cc: Rafael Fonseca 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" As types are slowly converted to GObject, a helper function to unref all the GObjects in an array will come in handy, as it's already the case with virObject. Signed-off-by: Rafael Fonseca --- src/libvirt_private.syms | 1 + src/util/virobject.c | 24 ++++++++++++++++++++++++ src/util/virobject.h | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2cde3c9aa5..4286efdd36 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2734,6 +2734,7 @@ virClassForObjectRWLockable; virClassIsDerivedFrom; virClassName; virClassNew; +virGObjectListFreeCount; virObjectFreeCallback; virObjectFreeHashData; virObjectIsClass; diff --git a/src/util/virobject.c b/src/util/virobject.c index c71781550f..9030fb1625 100644 --- a/src/util/virobject.c +++ b/src/util/virobject.c @@ -29,6 +29,7 @@ #include "virlog.h" #include "virprobe.h" #include "virstring.h" +#include =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 @@ -636,3 +637,26 @@ virObjectListFreeCount(void *list, =20 VIR_FREE(list); } + + +/** + * virGObjectListFreeCount: + * @list: A pointer to a list of GObject pointers to free + * @count: Number of elements in the list. + * + * Unrefs all members of @list and frees the list itself. + */ +void +virGObjectListFreeCount(void *list, + size_t count) +{ + size_t i; + + if (!list) + return; + + for (i =3D 0; i < count; i++) + g_clear_object(&((GObject **)list)[i]); + + VIR_FREE(list); +} diff --git a/src/util/virobject.h b/src/util/virobject.h index 62a8a3d132..1af048aefc 100644 --- a/src/util/virobject.h +++ b/src/util/virobject.h @@ -159,3 +159,7 @@ virObjectListFree(void *list); void virObjectListFreeCount(void *list, size_t count); + +void +virGObjectListFreeCount(void *list, + size_t count); --=20 2.25.3