mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-05 05:45:46 +00:00
tools: Use glib memory functions in vshCompleterFilter
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d91faa4fc3
commit
b668054209
10
tools/vsh.c
10
tools/vsh.c
@ -2709,13 +2709,11 @@ vshCompleterFilter(char ***list,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
list_len = virStringListLength((const char **) *list);
|
list_len = virStringListLength((const char **) *list);
|
||||||
|
newList = g_new0(char *, list_len + 1);
|
||||||
if (VIR_ALLOC_N(newList, list_len + 1) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < list_len; i++) {
|
for (i = 0; i < list_len; i++) {
|
||||||
if (!STRPREFIX((*list)[i], text)) {
|
if (!STRPREFIX((*list)[i], text)) {
|
||||||
VIR_FREE((*list)[i]);
|
g_clear_pointer(&(*list)[i], g_free);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2723,8 +2721,8 @@ vshCompleterFilter(char ***list,
|
|||||||
newList_len++;
|
newList_len++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ignore_value(VIR_REALLOC_N_QUIET(newList, newList_len + 1));
|
newList = g_renew(char *, newList, newList_len + 1);
|
||||||
VIR_FREE(*list);
|
g_free(*list);
|
||||||
*list = newList;
|
*list = newList;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user