mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
examples: domtop: Avoid leaking memory
Use the virTypedParamsFree unconditionally as it handles NULL well and has the benefit of freeing a typed parameter array even if it wasn't yet assigned, but only allocated.
This commit is contained in:
parent
abab113bd2
commit
ba2b4da02d
@ -334,12 +334,8 @@ do_top(virConnectPtr conn,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
if (max_id > 0) {
|
virTypedParamsFree(now_params, now_nparams * max_id);
|
||||||
if (now_nparams > 0)
|
virTypedParamsFree(then_params, then_nparams * max_id);
|
||||||
virTypedParamsFree(now_params, now_nparams * max_id);
|
|
||||||
if (then_nparams > 0)
|
|
||||||
virTypedParamsFree(then_params, then_nparams * max_id);
|
|
||||||
}
|
|
||||||
if (dom)
|
if (dom)
|
||||||
virDomainFree(dom);
|
virDomainFree(dom);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user