virshParseEventStr: Use g_strsplit and automatic memory freeing
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d338715dfb
commit
d7e2bca9b7
@ -9342,24 +9342,21 @@ virshParseEventStr(const char *event,
|
|||||||
int *nparams,
|
int *nparams,
|
||||||
int *maxparams)
|
int *maxparams)
|
||||||
{
|
{
|
||||||
char **tok = NULL;
|
g_auto(GStrv) tok = NULL;
|
||||||
size_t i, ntok;
|
GStrv next;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(tok = virStringSplitCount(event, ",", 0, &ntok)))
|
if (!(tok = g_strsplit(event, ",", 0)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < ntok; i++) {
|
for (next = tok; *next; next++) {
|
||||||
if ((*tok[i] != '\0') &&
|
if (*next[0] == '\0')
|
||||||
virTypedParamsAddBoolean(params, nparams,
|
continue;
|
||||||
maxparams, tok[i], state) < 0)
|
|
||||||
goto cleanup;
|
if (virTypedParamsAddBoolean(params, nparams, maxparams, *next, state) < 0)
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
g_strfreev(tok);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user