summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/strv.c28
-rw-r--r--src/shared/strv.h3
2 files changed, 31 insertions, 0 deletions
diff --git a/src/shared/strv.c b/src/shared/strv.c
index f86dddaf81..e418312d52 100644
--- a/src/shared/strv.c
+++ b/src/shared/strv.c
@@ -524,6 +524,16 @@ char **strv_uniq(char **l) {
return l;
}
+bool strv_is_uniq(char **l) {
+ char **i;
+
+ STRV_FOREACH(i, l)
+ if (strv_find(i+1, *i))
+ return false;
+
+ return true;
+}
+
char **strv_remove(char **l, const char *s) {
char **f, **t;
@@ -664,3 +674,21 @@ int strv_extendf(char ***l, const char *format, ...) {
return strv_consume(l, x);
}
+
+char **strv_reverse(char **l) {
+ unsigned n, i;
+
+ n = strv_length(l);
+ if (n <= 1)
+ return l;
+
+ for (i = 0; i < n / 2; i++) {
+ char *t;
+
+ t = l[i];
+ l[i] = l[n-1-i];
+ l[n-1-i] = t;
+ }
+
+ return l;
+}
diff --git a/src/shared/strv.h b/src/shared/strv.h
index 9e5b1bb8b0..e385bf73b8 100644
--- a/src/shared/strv.h
+++ b/src/shared/strv.h
@@ -52,6 +52,7 @@ int strv_consume_prepend(char ***l, char *value);
char **strv_remove(char **l, const char *s);
char **strv_uniq(char **l);
+bool strv_is_uniq(char **l);
bool strv_equal(char **a, char **b);
@@ -141,3 +142,5 @@ void strv_print(char **l);
_l ++; \
_l[0]; \
}))
+
+char **strv_reverse(char **l);