shared: add nm_utils_strv_make_deep_copied_n() helper
This commit is contained in:
@@ -2288,7 +2288,7 @@ nm_utils_strv_make_deep_copied (const char **strv)
|
|||||||
{
|
{
|
||||||
gsize i;
|
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*
|
* strings. Note that this updates @strv *in-place*
|
||||||
* and returns it. */
|
* and returns it. */
|
||||||
|
|
||||||
@@ -2300,6 +2300,23 @@ nm_utils_strv_make_deep_copied (const char **strv)
|
|||||||
return (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
|
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 (const char **strv);
|
||||||
|
|
||||||
|
char **nm_utils_strv_make_deep_copied_n (const char **strv, gsize len);
|
||||||
|
|
||||||
static inline char **
|
static inline char **
|
||||||
nm_utils_strv_make_deep_copied_nonnull (const char **strv)
|
nm_utils_strv_make_deep_copied_nonnull (const char **strv)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user