From: nicm Date: Thu, 7 May 2015 07:35:31 +0000 (+0000) Subject: Simplify environ_push so it doesn't need the ARRAY_* functions. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=023b89cde6d06e8a41baa6e9a243f38d92991024;p=openbsd Simplify environ_push so it doesn't need the ARRAY_* functions. --- diff --git a/usr.bin/tmux/environ.c b/usr.bin/tmux/environ.c index 38e7e7c0127..f5011be6f2b 100644 --- a/usr.bin/tmux/environ.c +++ b/usr.bin/tmux/environ.c @@ -1,4 +1,4 @@ -/* $OpenBSD: environ.c,v 1.7 2015/01/25 16:53:46 nicm Exp $ */ +/* $OpenBSD: environ.c,v 1.8 2015/05/07 07:35:31 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -157,23 +157,16 @@ environ_update(const char *vars, struct environ *srcenv, void environ_push(struct environ *env) { - ARRAY_DECL(, char *) varlist; - struct environ_entry *envent; - char **varp, *var; - u_int i; - - ARRAY_INIT(&varlist); - for (varp = environ; *varp != NULL; varp++) { - var = xstrdup(*varp); - var[strcspn(var, "=")] = '\0'; - ARRAY_ADD(&varlist, var); - } - for (i = 0; i < ARRAY_LENGTH(&varlist); i++) { - var = ARRAY_ITEM(&varlist, i); - unsetenv(var); - free(var); + struct environ_entry *envent; + char **vp, *v; + + for (vp = environ; *vp != NULL; vp++) { + v = xstrdup(*vp); + v[strcspn(v, "=")] = '\0'; + + unsetenv(v); + free(v); } - ARRAY_FREE(&varlist); RB_FOREACH(envent, environ, env) { if (envent->value != NULL)