提交 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;
virJSONValueGetNumberUint;
virJSONValueGetNumberUlong;
virJSONValueGetString;
virJSONValueHashFree;
virJSONValueIsArray;
virJSONValueIsNull;
virJSONValueNewArray;
......
......@@ -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,
......
......@@ -376,6 +376,14 @@ virJSONValueFree(virJSONValuePtr value)
}
void
virJSONValueHashFree(void *opaque,
const void *name ATTRIBUTE_UNUSED)
{
virJSONValueFree(opaque);
}
virJSONValuePtr
virJSONValueNewString(const char *data)
{
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册