chiark / gitweb /
cgroup: optionally mount a specific cgroup controllers together, and add cpu+cpuacct...
[elogind.git] / src / strv.c
index 71b77c9bbf97d857cce44ac0af1c350463d3ff50..a52440d832cc84b542fffe6398e4b6dbdc0588db 100644 (file)
@@ -67,11 +67,11 @@ void strv_free(char **l) {
 char **strv_copy(char **l) {
         char **r, **k;
 
-        if (!(r = new(char*, strv_length(l)+1)))
+        if (!(k = r = new(char*, strv_length(l)+1)))
                 return NULL;
 
         if (l)
-                for (k = r; *l; k++, l++)
+                for (; *l; k++, l++)
                         if (!(*k = strdup(*l)))
                                 goto fail;
 
@@ -105,7 +105,6 @@ char **strv_new_ap(const char *x, va_list ap) {
         unsigned n = 0, i = 0;
         va_list aq;
 
-
         if (x) {
                 n = 1;
 
@@ -661,3 +660,16 @@ char **strv_parse_nulstr(const char *s, size_t l) {
 
         return v;
 }
+
+bool strv_overlap(char **a, char **b) {
+        char **i, **j;
+
+        STRV_FOREACH(i, a) {
+                STRV_FOREACH(j, b) {
+                        if (streq(*i, *j))
+                                return true;
+                }
+        }
+
+        return false;
+}