mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: cmdDesc: Automatically free memory
Decrease scope of variables and use automatic freeing. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c344784b88
commit
5b811a199d
@ -8333,9 +8333,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
int state;
|
int state;
|
||||||
int type;
|
int type;
|
||||||
char *desc = NULL;
|
g_autofree char *desc = NULL;
|
||||||
char *desc_edited = NULL;
|
|
||||||
char *tmpstr;
|
|
||||||
const vshCmdOpt *opt = NULL;
|
const vshCmdOpt *opt = NULL;
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
@ -8379,6 +8377,8 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
if (edit) {
|
if (edit) {
|
||||||
g_autoptr(vshTempFile) tmp = NULL;
|
g_autoptr(vshTempFile) tmp = NULL;
|
||||||
|
g_autofree char *desc_edited = NULL;
|
||||||
|
char *tmpstr;
|
||||||
|
|
||||||
/* Create and open the temporary file. */
|
/* Create and open the temporary file. */
|
||||||
if (!(tmp = vshEditWriteToTempFile(ctl, desc)))
|
if (!(tmp = vshEditWriteToTempFile(ctl, desc)))
|
||||||
@ -8438,8 +8438,6 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(desc_edited);
|
|
||||||
VIR_FREE(desc);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user