X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fstrv.c;h=71b77c9bbf97d857cce44ac0af1c350463d3ff50;hp=1c15ee802c732581a69219e6ee127fa0ef2decc2;hb=7640a5de1b3ffe6547200ad204d14e4f067caf4f;hpb=25e3655a00ba41424c95222aba71c543e84fd3e3;ds=sidebyside diff --git a/src/strv.c b/src/strv.c index 1c15ee802..71b77c9bb 100644 --- a/src/strv.c +++ b/src/strv.c @@ -525,6 +525,32 @@ char **strv_env_delete(char **x, unsigned n_lists, ...) { return r; } +char **strv_env_unset(char **l, const char *p) { + + char **f, **t; + + if (!l) + return NULL; + + assert(p); + + /* Drops every occurrence of the env var setting p in the + * string list. edits in-place. */ + + for (f = t = l; *f; f++) { + + if (env_match(*f, p)) { + free(*f); + continue; + } + + *(t++) = *f; + } + + *t = NULL; + return l; +} + char **strv_env_set(char **x, const char *p) { char **k, **r;