提交 432452eb 编写于 作者: P Peter Krempa

qemu: qapi: Use automatic memory cleanup

Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 ec0483ae
......@@ -207,7 +207,7 @@ virQEMUQAPISchemaPathGet(const char *query,
virHashTablePtr schema,
virJSONValuePtr *entry)
{
char **elems = NULL;
VIR_AUTOSTRINGLIST elems = NULL;
*entry = NULL;
......@@ -216,13 +216,11 @@ virQEMUQAPISchemaPathGet(const char *query,
if (!*elems) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed query string"));
virStringListFree(elems);
return -1;
}
*entry = virQEMUQAPISchemaTraverse(*elems, elems + 1, schema);
virStringListFree(elems);
return 0;
}
......@@ -270,21 +268,16 @@ virQEMUQAPISchemaEntryProcess(size_t pos ATTRIBUTE_UNUSED,
virHashTablePtr
virQEMUQAPISchemaConvert(virJSONValuePtr schemareply)
{
virHashTablePtr schema;
virHashTablePtr ret = NULL;
VIR_AUTOPTR(virHashTable) schema = NULL;
VIR_AUTOPTR(virJSONValue) schemajson = schemareply;
if (!(schema = virHashCreate(512, virJSONValueHashFree)))
goto cleanup;
return NULL;
if (virJSONValueArrayForeachSteal(schemareply,
if (virJSONValueArrayForeachSteal(schemajson,
virQEMUQAPISchemaEntryProcess,
schema) < 0)
goto cleanup;
VIR_STEAL_PTR(ret, schema);
return NULL;
cleanup:
virJSONValueFree(schemareply);
virHashFree(schema);
return ret;
VIR_RETURN_PTR(schema);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册