shared: add nm_utils_strv_make_deep_copied_n() helper

This commit is contained in:
Thomas Haller
2019-05-09 14:01:44 +02:00
parent 79ef1abcca
commit dadd38c484
2 changed files with 20 additions and 1 deletions

View File

@@ -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

View File

@@ -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)
{