mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
qemu: block: Use VIR_AUTOPTR for virHashTablePtr
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
bc6eabbec3
commit
ae0c36ecbb
@ -240,8 +240,8 @@ qemuBlockNodeNameGetBackingChain(virJSONValuePtr namednodes,
|
|||||||
virJSONValuePtr blockstats)
|
virJSONValuePtr blockstats)
|
||||||
{
|
{
|
||||||
struct qemuBlockNodeNameGetBackingChainData data;
|
struct qemuBlockNodeNameGetBackingChainData data;
|
||||||
virHashTablePtr namednodestable = NULL;
|
VIR_AUTOPTR(virHashTable) namednodestable = NULL;
|
||||||
virHashTablePtr disks = NULL;
|
VIR_AUTOPTR(virHashTable) disks = NULL;
|
||||||
virHashTablePtr ret = NULL;
|
virHashTablePtr ret = NULL;
|
||||||
|
|
||||||
memset(&data, 0, sizeof(data));
|
memset(&data, 0, sizeof(data));
|
||||||
@ -268,8 +268,6 @@ qemuBlockNodeNameGetBackingChain(virJSONValuePtr namednodes,
|
|||||||
VIR_STEAL_PTR(ret, disks);
|
VIR_STEAL_PTR(ret, disks);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virHashFree(namednodestable);
|
|
||||||
virHashFree(disks);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -344,7 +342,7 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
|
|||||||
qemuDomainAsyncJob asyncJob)
|
qemuDomainAsyncJob asyncJob)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virHashTablePtr disktable = NULL;
|
VIR_AUTOPTR(virHashTable) disktable = NULL;
|
||||||
VIR_AUTOPTR(virJSONValue) data = NULL;
|
VIR_AUTOPTR(virJSONValue) data = NULL;
|
||||||
VIR_AUTOPTR(virJSONValue) blockstats = NULL;
|
VIR_AUTOPTR(virJSONValue) blockstats = NULL;
|
||||||
virDomainDiskDefPtr disk;
|
virDomainDiskDefPtr disk;
|
||||||
@ -376,7 +374,6 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virHashFree(disktable);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -394,19 +391,20 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
|
|||||||
virHashTablePtr
|
virHashTablePtr
|
||||||
qemuBlockGetNodeData(virJSONValuePtr data)
|
qemuBlockGetNodeData(virJSONValuePtr data)
|
||||||
{
|
{
|
||||||
|
VIR_AUTOPTR(virHashTable) nodedata = NULL;
|
||||||
virHashTablePtr ret = NULL;
|
virHashTablePtr ret = NULL;
|
||||||
|
|
||||||
if (!(ret = virHashCreate(50, virJSONValueHashFree)))
|
if (!(nodedata = virHashCreate(50, virJSONValueHashFree)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (virJSONValueArrayForeachSteal(data,
|
if (virJSONValueArrayForeachSteal(data,
|
||||||
qemuBlockNamedNodesArrayToHash, ret) < 0)
|
qemuBlockNamedNodesArrayToHash, nodedata) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
VIR_STEAL_PTR(ret, nodedata);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virHashFree(ret);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user