summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-08-24 01:10:13 +0200
committerLennart Poettering <lennart@poettering.net>2011-08-24 01:10:13 +0200
commit700de55514bc3137bb90aa87326f2ed80e675dda (patch)
tree127fba17ea2ab41b5c596e5a11f95943ac8648af /src
parent944d6c04270932cbfb1baf3e24a127d31531904f (diff)
strv: fix counting in strv_env_delete()
Diffstat (limited to 'src')
-rw-r--r--src/strv.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/strv.c b/src/strv.c
index a52440d832..92851b2233 100644
--- a/src/strv.c
+++ b/src/strv.c
@@ -482,8 +482,8 @@ static bool env_match(const char *t, const char *pattern) {
}
char **strv_env_delete(char **x, unsigned n_lists, ...) {
- size_t n = 0, i = 0;
- char **l, **k, **r, **j;
+ size_t n, i = 0;
+ char **k, **r;
va_list ap;
/* Deletes every entry from x that is mentioned in the other
@@ -491,29 +491,34 @@ char **strv_env_delete(char **x, unsigned n_lists, ...) {
n = strv_length(x);
- if (!(r = new(char*, n+1)))
+ r = new(char*, n+1);
+ if (!r)
return NULL;
STRV_FOREACH(k, x) {
+ unsigned v;
+
va_start(ap, n_lists);
+ for (v = 0; v < n_lists; v++) {
+ char **l, **j;
- for (i = 0; i < n_lists; i++) {
l = va_arg(ap, char**);
STRV_FOREACH(j, l)
if (env_match(*k, *j))
- goto delete;
+ goto skip;
}
-
va_end(ap);
- if (!(r[i++] = strdup(*k))) {
+ r[i] = strdup(*k);
+ if (!r[i]) {
strv_free(r);
return NULL;
}
+ i++;
continue;
- delete:
+ skip:
va_end(ap);
}