summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-08-25 11:51:32 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2020-08-26 17:08:00 +0200
commit418d20acc9c241cbd5a832a21ddbc9946b8815ca (patch)
tree60a7cb52d457c56c7bf4c52962548e2eef456e3a
parentdbab673f7664dbd9312060314192584e28bdc462 (diff)
downloadNetworkManager-418d20acc9c241cbd5a832a21ddbc9946b8815ca.tar.gz
shared: add nm_strvarray_remove_first()
Co-authored-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h
index a1e142d3ff..cf13142ddf 100644
--- a/shared/nm-glib-aux/nm-shared-utils.h
+++ b/shared/nm-glib-aux/nm-shared-utils.h
@@ -2190,6 +2190,24 @@ nm_strvarray_set_strv (GArray **array, const char *const*strv)
nm_strvarray_add (*array, strv[0]);
}
+static inline gboolean
+nm_strvarray_remove_first (GArray *strv, const char *needle)
+{
+ guint i;
+
+ nm_assert (needle);
+
+ if (strv) {
+ for (i = 0; i < strv->len; i++) {
+ if (nm_streq (needle, g_array_index (strv, const char *, i))) {
+ g_array_remove_index (strv, i);
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
/*****************************************************************************/
struct _NMVariantAttributeSpec {