summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-07-23 10:50:53 +0200
committerThomas Haller <thaller@redhat.com>2020-07-24 16:03:15 +0200
commita8517423c73783a5f182b925ebda063d481f1330 (patch)
tree44894a14e18a499b092065086f4caa1efcc88c66
parentc470cbf7058df38db44301c5cc09fd2191e2bf7d (diff)
downloadNetworkManager-a8517423c73783a5f182b925ebda063d481f1330.tar.gz
shared: add nm_strv_ptrarray_clone() helper
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h
index f90f7629af..2f6681cb70 100644
--- a/shared/nm-glib-aux/nm-shared-utils.h
+++ b/shared/nm-glib-aux/nm-shared-utils.h
@@ -1809,6 +1809,16 @@ nm_strv_ptrarray_ensure (GPtrArray **p_arr)
return *p_arr;
}
+static inline GPtrArray *
+nm_strv_ptrarray_clone (const GPtrArray *src, gboolean null_if_empty)
+{
+ if ( !src
+ || ( null_if_empty
+ && src->len == 0))
+ return NULL;
+ return nm_g_ptr_array_copy ((GPtrArray *) src, nm_copy_func_g_strdup, NULL, g_free);
+}
+
static inline void
nm_strv_ptrarray_add_string_take (GPtrArray *cmd,
char *str)