Simplify environ_push so it doesn't need the ARRAY_* functions.
authornicm <nicm@openbsd.org>
Thu, 7 May 2015 07:35:31 +0000 (07:35 +0000)
committernicm <nicm@openbsd.org>
Thu, 7 May 2015 07:35:31 +0000 (07:35 +0000)
usr.bin/tmux/environ.c

index 38e7e7c..f5011be 100644 (file)
@@ -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)