]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: json: Make function to free JSON values in virHash universal
authorPeter Krempa <pkrempa@redhat.com>
Thu, 16 Mar 2017 09:19:32 +0000 (10:19 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 27 Mar 2017 08:35:19 +0000 (10:35 +0200)
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
src/qemu/qemu_monitor_json.c
src/util/virjson.c
src/util/virjson.h

index ead2149dd038493151d6e4e050015e4eccea5294..744779ad222e2e92845f2bb7b909ae64fc47da8b 100644 (file)
@@ -1835,6 +1835,7 @@ virJSONValueGetNumberLong;
 virJSONValueGetNumberUint;
 virJSONValueGetNumberUlong;
 virJSONValueGetString;
+virJSONValueHashFree;
 virJSONValueIsArray;
 virJSONValueIsNull;
 virJSONValueNewArray;
index 35ee72cf18d3a64e10eacaf3e0bcf9f37261106e..e68c31ef45b75d405f9f91817cb514c5961f868f 100644 (file)
@@ -7488,14 +7488,6 @@ qemuMonitorJSONFillQMPSchema(size_t pos ATTRIBUTE_UNUSED,
 }
 
 
-static void
-qemuMonitorJSONFreeSchemaEntry(void *opaque,
-                               const void *name ATTRIBUTE_UNUSED)
-{
-    virJSONValueFree(opaque);
-}
-
-
 virHashTablePtr
 qemuMonitorJSONQueryQMPSchema(qemuMonitorPtr mon)
 {
@@ -7516,7 +7508,7 @@ qemuMonitorJSONQueryQMPSchema(qemuMonitorPtr mon)
 
     arr = virJSONValueObjectGet(reply, "return");
 
-    if (!(schema = virHashCreate(512, qemuMonitorJSONFreeSchemaEntry)))
+    if (!(schema = virHashCreate(512, virJSONValueHashFree)))
         goto cleanup;
 
     if (virJSONValueArrayForeachSteal(arr, qemuMonitorJSONFillQMPSchema,
index c907b5ded1c11d7ba77d7b72dd4de65ceebe47e5..b49b29b0fb01c38e80ae15adde9a6990b1ee24c8 100644 (file)
@@ -376,6 +376,14 @@ virJSONValueFree(virJSONValuePtr value)
 }
 
 
+void
+virJSONValueHashFree(void *opaque,
+                     const void *name ATTRIBUTE_UNUSED)
+{
+    virJSONValueFree(opaque);
+}
+
+
 virJSONValuePtr
 virJSONValueNewString(const char *data)
 {
index 5e32cb9a411f03c4891de3299950b74afc6f2496..14b74c0617c9719e5269e60306dc4b7c789559d4 100644 (file)
@@ -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;