util: Rework virStringListAdd

So every caller does the same: they use virStringListAdd() to add
new item into the list and then free the old copy to replace it
with new list. It's not very memory effective, nor environmental
friendly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Michal Privoznik
2018-07-26 16:10:10 +02:00
parent f2a519a506
commit 71a390e0fd
4 changed files with 17 additions and 34 deletions

View File

@@ -179,12 +179,8 @@ static int testAdd(const void *args)
size_t i;
for (i = 0; data->tokens[i]; i++) {
char **tmp = virStringListAdd((const char **)list, data->tokens[i]);
if (!tmp)
if (virStringListAdd(&list, data->tokens[i]) < 0)
goto cleanup;
virStringListFree(list);
list = tmp;
tmp = NULL;
}
if (!list &&