summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-11-15 11:56:23 +0100
committerThomas Haller <thaller@redhat.com>2023-11-15 17:59:25 +0100
commit60375218d1389765f7791f1716c8eddbf1935f9d (patch)
tree10448599cec65f283518aa48ac98d2e0ecc7a4f3
parent6c83f7bd67916c67071e6252f51f7aa37b3f675f (diff)
glib-aux: add nm_strvarray_remove_index() helper
-rw-r--r--src/libnm-glib-aux/nm-shared-utils.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h
index 9d98e86f46..90e10c13e9 100644
--- a/src/libnm-glib-aux/nm-shared-utils.h
+++ b/src/libnm-glib-aux/nm-shared-utils.h
@@ -3128,6 +3128,20 @@ nm_strvarray_remove_first(GArray *strv, const char *needle)
return TRUE;
}
+#define nm_strvarray_remove_index(strv, idx) \
+ G_STMT_START \
+ { \
+ GArray *const _strv = (strv); \
+ typeof(idx) _idx = (idx); \
+ \
+ nm_assert(_strv); \
+ nm_assert((uintmax_t) _idx < _strv->len); \
+ nm_assert(sizeof(char *) == g_array_get_element_size(_strv)); \
+ \
+ g_array_remove_index(_strv, (guint) _idx); \
+ } \
+ G_STMT_END
+
static inline void
nm_strvarray_ensure_and_add(GArray **p, const char *str)
{