mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-10 12:50:17 +01:00
shared: add nm_utils_strv_make_deep_copied_n() helper
This commit is contained in:
parent
79ef1abcca
commit
dadd38c484
2 changed files with 20 additions and 1 deletions
|
|
@ -2288,7 +2288,7 @@ nm_utils_strv_make_deep_copied (const char **strv)
|
|||
{
|
||||
gsize i;
|
||||
|
||||
/* it takes a strv dictionary, and copies each
|
||||
/* it takes a strv list, and copies each
|
||||
* strings. Note that this updates @strv *in-place*
|
||||
* and returns it. */
|
||||
|
||||
|
|
@ -2300,6 +2300,23 @@ nm_utils_strv_make_deep_copied (const char **strv)
|
|||
return (char **) strv;
|
||||
}
|
||||
|
||||
char **
|
||||
nm_utils_strv_make_deep_copied_n (const char **strv, gsize len)
|
||||
{
|
||||
gsize i;
|
||||
|
||||
/* it takes a strv array with len elements, and copies each
|
||||
* strings. Note that this updates @strv *in-place*
|
||||
* and returns it. */
|
||||
|
||||
if (!strv)
|
||||
return NULL;
|
||||
for (i = 0; i < len; i++)
|
||||
strv[i] = g_strdup (strv[i]);
|
||||
|
||||
return (char **) strv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gssize
|
||||
|
|
|
|||
|
|
@ -951,6 +951,8 @@ nm_utils_strdict_get_keys (const GHashTable *hash,
|
|||
|
||||
char **nm_utils_strv_make_deep_copied (const char **strv);
|
||||
|
||||
char **nm_utils_strv_make_deep_copied_n (const char **strv, gsize len);
|
||||
|
||||
static inline char **
|
||||
nm_utils_strv_make_deep_copied_nonnull (const char **strv)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue