chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
journal: add missing sd-messages.h
[elogind.git]
/
src
/
strv.c
diff --git
a/src/strv.c
b/src/strv.c
index a52440d832cc84b542fffe6398e4b6dbdc0588db..bb309d9f92510feb1c622e20f91e6b9e6b46f15a 100644
(file)
--- a/
src/strv.c
+++ b/
src/strv.c
@@
-67,7
+67,8
@@
void strv_free(char **l) {
char **strv_copy(char **l) {
char **r, **k;
char **strv_copy(char **l) {
char **r, **k;
- if (!(k = r = new(char*, strv_length(l)+1)))
+ k = r = new(char*, strv_length(l)+1);
+ if (!k)
return NULL;
if (l)
return NULL;
if (l)
@@
-198,15
+199,23
@@
char **strv_merge_concat(char **a, char **b, const char *suffix) {
if (!b)
return strv_copy(a);
if (!b)
return strv_copy(a);
- if (!(r = new(char*, strv_length(a)+strv_length(b)+1)))
+ r = new(char*, strv_length(a) + strv_length(b) + 1);
+ if (!r)
return NULL;
return NULL;
- for (k = r; *a; k++, a++)
- if (!(*k = strdup(*a)))
- goto fail;
- for (; *b; k++, b++)
- if (!(*k = strappend(*b, suffix)))
+ k = r;
+ if (a)
+ for (; *a; k++, a++) {
+ *k = strdup(*a);
+ if (!*k)
+ goto fail;
+ }
+
+ for (; *b; k++, b++) {
+ *k = strappend(*b, suffix);
+ if (!*k)
goto fail;
goto fail;
+ }
*k = NULL;
return r;
*k = NULL;
return r;
@@
-317,7
+326,8
@@
char **strv_append(char **l, const char *s) {
if (!s)
return strv_copy(l);
if (!s)
return strv_copy(l);
- if (!(r = new(char*, strv_length(l)+2)))
+ r = new(char*, strv_length(l)+2);
+ if (!r)
return NULL;
for (k = r; *l; k++, l++)
return NULL;
for (k = r; *l; k++, l++)
@@
-482,8
+492,8
@@
static bool env_match(const char *t, const char *pattern) {
}
char **strv_env_delete(char **x, unsigned n_lists, ...) {
}
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
va_list ap;
/* Deletes every entry from x that is mentioned in the other
@@
-491,29
+501,34
@@
char **strv_env_delete(char **x, unsigned n_lists, ...) {
n = strv_length(x);
n = strv_length(x);
- if (!(r = new(char*, n+1)))
+ r = new(char*, n+1);
+ if (!r)
return NULL;
STRV_FOREACH(k, x) {
return NULL;
STRV_FOREACH(k, x) {
+ unsigned v;
+
va_start(ap, n_lists);
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))
l = va_arg(ap, char**);
STRV_FOREACH(j, l)
if (env_match(*k, *j))
- goto
delete
;
+ goto
skip
;
}
}
-
va_end(ap);
va_end(ap);
- if (!(r[i++] = strdup(*k))) {
+ r[i] = strdup(*k);
+ if (!r[i]) {
strv_free(r);
return NULL;
}
strv_free(r);
return NULL;
}
+ i++;
continue;
continue;
-
delete
:
+
skip
:
va_end(ap);
}
va_end(ap);
}