From nobody Sun Feb 8 05:42:03 2026 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1489678146947558.0157670739353; Thu, 16 Mar 2017 08:29:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 820353D962; Thu, 16 Mar 2017 15:29:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 54DB7183A7; Thu, 16 Mar 2017 15:29:06 +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 0584B5EC62; Thu, 16 Mar 2017 15:29:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2GFSvWJ004002 for ; Thu, 16 Mar 2017 11:28:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id B057C183A0; Thu, 16 Mar 2017 15:28:57 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C92060F8A; Thu, 16 Mar 2017 15:28:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 820353D962 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 820353D962 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 16 Mar 2017 16:29:49 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 1/3] util: json: Make function to free JSON values in virHash universal 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: , MIME-Version: 1.0 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 16 Mar 2017 15:29:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the helper that frees JSON entries put into hash tables into the JSON module so that it does not have to be reimplemented. --- src/libvirt_private.syms | 1 + src/qemu/qemu_monitor_json.c | 10 +--------- src/util/virjson.c | 8 ++++++++ src/util/virjson.h | 1 + 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index db0e11e33..84619f01f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1832,6 +1832,7 @@ virJSONValueGetNumberLong; virJSONValueGetNumberUint; virJSONValueGetNumberUlong; virJSONValueGetString; +virJSONValueHashFree; virJSONValueIsArray; virJSONValueIsNull; virJSONValueNewArray; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 75af5cb93..e6b73d340 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7449,14 +7449,6 @@ qemuMonitorJSONFillQMPSchema(size_t pos ATTRIBUTE_UN= USED, } -static void -qemuMonitorJSONFreeSchemaEntry(void *opaque, - const void *name ATTRIBUTE_UNUSED) -{ - virJSONValueFree(opaque); -} - - virHashTablePtr qemuMonitorJSONQueryQMPSchema(qemuMonitorPtr mon) { @@ -7477,7 +7469,7 @@ qemuMonitorJSONQueryQMPSchema(qemuMonitorPtr mon) arr =3D virJSONValueObjectGet(reply, "return"); - if (!(schema =3D virHashCreate(512, qemuMonitorJSONFreeSchemaEntry))) + if (!(schema =3D virHashCreate(512, virJSONValueHashFree))) goto cleanup; if (virJSONValueArrayForeachSteal(arr, qemuMonitorJSONFillQMPSchema, diff --git a/src/util/virjson.c b/src/util/virjson.c index c907b5ded..b49b29b0f 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -376,6 +376,14 @@ virJSONValueFree(virJSONValuePtr value) } +void +virJSONValueHashFree(void *opaque, + const void *name ATTRIBUTE_UNUSED) +{ + virJSONValueFree(opaque); +} + + virJSONValuePtr virJSONValueNewString(const char *data) { diff --git a/src/util/virjson.h b/src/util/virjson.h index 5e32cb9a4..14b74c061 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -81,6 +81,7 @@ struct _virJSONValue { }; void virJSONValueFree(virJSONValuePtr value); +void virJSONValueHashFree(void *opaque, const void *name); int virJSONValueObjectCreate(virJSONValuePtr *obj, ...) ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL; --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list