From b6680542093b170276daaf186930a990e6f46bef Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Fri, 11 Sep 2020 13:42:16 +0200 Subject: [PATCH] tools: Use glib memory functions in vshCompleterFilter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tim Wiederhake Reviewed-by: Ján Tomko Signed-off-by: Ján Tomko --- tools/vsh.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 0e8edcd78c..e3c2404a74 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2709,13 +2709,11 @@ vshCompleterFilter(char ***list, return -1; list_len = virStringListLength((const char **) *list); - - if (VIR_ALLOC_N(newList, list_len + 1) < 0) - return -1; + newList = g_new0(char *, list_len + 1); for (i = 0; i < list_len; i++) { if (!STRPREFIX((*list)[i], text)) { - VIR_FREE((*list)[i]); + g_clear_pointer(&(*list)[i], g_free); continue; } @@ -2723,8 +2721,8 @@ vshCompleterFilter(char ***list, newList_len++; } - ignore_value(VIR_REALLOC_N_QUIET(newList, newList_len + 1)); - VIR_FREE(*list); + newList = g_renew(char *, newList, newList_len + 1); + g_free(*list); *list = newList; return 0; }