summaryrefslogtreecommitdiff
path: root/src/shared/strv.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-12-19 01:31:59 +0100
committerLennart Poettering <lennart@poettering.net>2014-12-19 02:07:42 +0100
commite1dd6790e4f58506e637bf9541f63504acc2972f (patch)
tree6f55a9d1fbb5531f6d0337f7e939b1d6b41f7d37 /src/shared/strv.c
parent24167f3db842238e4e9115db36eff947be46da5f (diff)
strv: ass new strv_is_uniq() and strv_reverse() calls
Diffstat (limited to 'src/shared/strv.c')
-rw-r--r--src/shared/strv.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/shared/strv.c b/src/shared/strv.c
index f86dddaf8..e418312d5 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;
+}