const vshCmdGrp *grp;
const vshCmdDef *cmds;
size_t ret_size = 0;
- char **ret = NULL;
+ g_auto(GStrv) ret = NULL;
grp = cmdGroups;
continue;
if (STRPREFIX(name, text)) {
- if (VIR_REALLOC_N(ret, ret_size + 2) < 0) {
- g_strfreev(ret);
+ if (VIR_REALLOC_N(ret, ret_size + 2) < 0)
return NULL;
- }
+
ret[ret_size] = g_strdup(name);
ret_size++;
/* Terminate the string list properly. */
}
}
- return ret;
+ return g_steal_pointer(&ret);
}
static char **
size_t list_index = 0;
size_t len = strlen(text);
size_t ret_size = 0;
- char **ret = NULL;
+ g_auto(GStrv) ret = NULL;
if (!cmd)
return NULL;
if (exists)
continue;
- if (VIR_REALLOC_N(ret, ret_size + 2) < 0) {
- g_strfreev(ret);
+ if (VIR_REALLOC_N(ret, ret_size + 2) < 0)
return NULL;
- }
ret[ret_size] = g_strdup_printf("--%s", name);
ret_size++;
ret[ret_size] = NULL;
}
- return ret;
+ return g_steal_pointer(&ret);
}