mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
util: remove virStringListCopy
The g_strdupv function from GLib provides the same functionality. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
1d40d83336
commit
201dcc1690
@ -259,43 +259,6 @@ virStringListMerge(char ***dst,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virStringListCopy:
|
||||
* @dst: where to store the copy of @strings
|
||||
* @src: a NULL-terminated array of strings
|
||||
*
|
||||
* Makes a deep copy of the @src string list and stores it in @dst. Callers
|
||||
* are responsible for freeing @dst.
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
virStringListCopy(char ***dst,
|
||||
const char **src)
|
||||
{
|
||||
char **copy = NULL;
|
||||
size_t i;
|
||||
|
||||
*dst = NULL;
|
||||
|
||||
if (!src)
|
||||
return 0;
|
||||
|
||||
if (VIR_ALLOC_N(copy, virStringListLength(src) + 1) < 0)
|
||||
goto error;
|
||||
|
||||
for (i = 0; src[i]; i++)
|
||||
copy[i] = g_strdup(src[i]);
|
||||
|
||||
*dst = copy;
|
||||
return 0;
|
||||
|
||||
error:
|
||||
virStringListFree(copy);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virStringListFree:
|
||||
* @strings: a NULL-terminated array of strings to free
|
||||
|
@ -45,9 +45,6 @@ void virStringListRemove(char ***strings,
|
||||
int virStringListMerge(char ***dst,
|
||||
char ***src);
|
||||
|
||||
int virStringListCopy(char ***dst,
|
||||
const char **src);
|
||||
|
||||
void virStringListFree(char **strings);
|
||||
void virStringListAutoFree(char ***strings);
|
||||
void virStringListFreeCount(char **strings,
|
||||
|
Loading…
x
Reference in New Issue
Block a user