X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fstrv.c;h=e418312d52a6a9cb28a25994971591431f651f42;hb=978553ce5e85a57a203be8256e59f304c8c46f3d;hp=f86dddaf811223b0df1caa8f71c6f0c316440f7b;hpb=dd9c7723fafc8b326188efa86efe00bcbe5abcfd;p=elogind.git 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; +}