提交 86e51d68 编写于 作者: P Peter Krempa

util: json: Make function to free JSON values in virHash universal

Move the helper that frees JSON entries put into hash tables into the
JSON module so that it does not have to be reimplemented.
上级 0feebab2
...@@ -1835,6 +1835,7 @@ virJSONValueGetNumberLong; ...@@ -1835,6 +1835,7 @@ virJSONValueGetNumberLong;
virJSONValueGetNumberUint; virJSONValueGetNumberUint;
virJSONValueGetNumberUlong; virJSONValueGetNumberUlong;
virJSONValueGetString; virJSONValueGetString;
virJSONValueHashFree;
virJSONValueIsArray; virJSONValueIsArray;
virJSONValueIsNull; virJSONValueIsNull;
virJSONValueNewArray; virJSONValueNewArray;
......
...@@ -7488,14 +7488,6 @@ qemuMonitorJSONFillQMPSchema(size_t pos ATTRIBUTE_UNUSED, ...@@ -7488,14 +7488,6 @@ qemuMonitorJSONFillQMPSchema(size_t pos ATTRIBUTE_UNUSED,
} }
static void
qemuMonitorJSONFreeSchemaEntry(void *opaque,
const void *name ATTRIBUTE_UNUSED)
{
virJSONValueFree(opaque);
}
virHashTablePtr virHashTablePtr
qemuMonitorJSONQueryQMPSchema(qemuMonitorPtr mon) qemuMonitorJSONQueryQMPSchema(qemuMonitorPtr mon)
{ {
...@@ -7516,7 +7508,7 @@ qemuMonitorJSONQueryQMPSchema(qemuMonitorPtr mon) ...@@ -7516,7 +7508,7 @@ qemuMonitorJSONQueryQMPSchema(qemuMonitorPtr mon)
arr = virJSONValueObjectGet(reply, "return"); arr = virJSONValueObjectGet(reply, "return");
if (!(schema = virHashCreate(512, qemuMonitorJSONFreeSchemaEntry))) if (!(schema = virHashCreate(512, virJSONValueHashFree)))
goto cleanup; goto cleanup;
if (virJSONValueArrayForeachSteal(arr, qemuMonitorJSONFillQMPSchema, if (virJSONValueArrayForeachSteal(arr, qemuMonitorJSONFillQMPSchema,
......
...@@ -376,6 +376,14 @@ virJSONValueFree(virJSONValuePtr value) ...@@ -376,6 +376,14 @@ virJSONValueFree(virJSONValuePtr value)
} }
void
virJSONValueHashFree(void *opaque,
const void *name ATTRIBUTE_UNUSED)
{
virJSONValueFree(opaque);
}
virJSONValuePtr virJSONValuePtr
virJSONValueNewString(const char *data) virJSONValueNewString(const char *data)
{ {
......
...@@ -81,6 +81,7 @@ struct _virJSONValue { ...@@ -81,6 +81,7 @@ struct _virJSONValue {
}; };
void virJSONValueFree(virJSONValuePtr value); void virJSONValueFree(virJSONValuePtr value);
void virJSONValueHashFree(void *opaque, const void *name);
int virJSONValueObjectCreate(virJSONValuePtr *obj, ...) int virJSONValueObjectCreate(virJSONValuePtr *obj, ...)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL; ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册