mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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:
@@ -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 &&
|
||||
|
||||
Reference in New Issue
Block a user