mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-06 00:43:48 +00:00
vshReadlineParse: Use g_auto*()
Instead of freeing @partial and @buf explicitly, we can use g_auto*() to do that automatically. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
e19ecee54c
commit
100052135f
10
tools/vsh.c
10
tools/vsh.c
@ -739,6 +739,8 @@ vshCommandFree(vshCmd *cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(vshCmd, vshCommandFree);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vshCommandOpt:
|
* vshCommandOpt:
|
||||||
* @cmd: parsed command line to search
|
* @cmd: parsed command line to search
|
||||||
@ -2704,10 +2706,10 @@ vshReadlineParse(const char *text, int state)
|
|||||||
* initialize those static variables above. On subsequent
|
* initialize those static variables above. On subsequent
|
||||||
* calls @state is non zero. */
|
* calls @state is non zero. */
|
||||||
if (!state) {
|
if (!state) {
|
||||||
vshCmd *partial = NULL;
|
g_autoptr(vshCmd) partial = NULL;
|
||||||
const vshCmdDef *cmd = NULL;
|
const vshCmdDef *cmd = NULL;
|
||||||
const vshCmdOptDef *opt = NULL;
|
const vshCmdOptDef *opt = NULL;
|
||||||
char *buf = g_strdup(rl_line_buffer);
|
g_autofree char *buf = g_strdup(rl_line_buffer);
|
||||||
|
|
||||||
g_strfreev(list);
|
g_strfreev(list);
|
||||||
list = NULL;
|
list = NULL;
|
||||||
@ -2717,8 +2719,6 @@ vshReadlineParse(const char *text, int state)
|
|||||||
|
|
||||||
vshCommandStringParse(NULL, buf, &partial);
|
vshCommandStringParse(NULL, buf, &partial);
|
||||||
|
|
||||||
VIR_FREE(buf);
|
|
||||||
|
|
||||||
if (partial) {
|
if (partial) {
|
||||||
cmd = partial->def;
|
cmd = partial->def;
|
||||||
partial->skipChecks = true;
|
partial->skipChecks = true;
|
||||||
@ -2759,12 +2759,10 @@ vshReadlineParse(const char *text, int state)
|
|||||||
(vshCompleterFilter(&completer_list, text) < 0 ||
|
(vshCompleterFilter(&completer_list, text) < 0 ||
|
||||||
virStringListMerge(&list, &completer_list) < 0)) {
|
virStringListMerge(&list, &completer_list) < 0)) {
|
||||||
g_strfreev(completer_list);
|
g_strfreev(completer_list);
|
||||||
vshCommandFree(partial);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vshCommandFree(partial);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list) {
|
if (list) {
|
||||||
|
Loading…
Reference in New Issue
Block a user