summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-05-07 07:35:32 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-05-07 07:35:32 +0000
commitb0b291dcde64e3e563f9eee9c45c65b77f0d4129 (patch)
tree78c80e7408b88fc2d7e3dedd37022a5a3a420c09
parentda2766bb6436a54ab2bfb9fa2523f09a896f479d (diff)
Simplify environ_push so it doesn't need the ARRAY_* functions.
-rw-r--r--usr.bin/tmux/environ.c27
1 files changed, 10 insertions, 17 deletions
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 <nicm@users.sourceforge.net>
@@ -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)