]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: Remove workaround in environ.cc
authorKen Brown <kbrown@cornell.edu>
Wed, 6 Jun 2018 15:45:57 +0000 (11:45 -0400)
committerCorinna Vinschen <corinna@vinschen.de>
Thu, 7 Jun 2018 07:42:36 +0000 (09:42 +0200)
Commit ebd645e on 2001-10-03 made environ.cc:_addenv() add unneeded
space at the end of the environment block to "work around problems
with some buggy applications."  This clutters the code and is
presumably no longer needed.

winsup/cygwin/environ.cc

index bbe539816ee92c37733beb965ff4f47c17a1d087..67ead1ddec5e96583c0633ef1f160123772328c1 100644 (file)
@@ -592,13 +592,11 @@ _addenv (const char *name, const char *value, int overwrite)
     {                          /* Create new slot. */
       int sz = envsize (cur_environ ());
 
-      /* If sz == 0, we need two new slots, one for the terminating NULL.
-        But we add two slots in all cases, as has been done since
-        2001-10-03 (commit ebd645e) to "work around problems with
-        some buggy applications." */
-      int allocsz = (sz + 2) * sizeof (char *);
+      /* If sz == 0, we need two new slots, one for the terminating NULL. */
+      int newsz = sz == 0 ? 2 : sz + 1;
+      int allocsz = newsz * sizeof (char *);
 
-      offset = sz == 0 ? 0 : sz - 1;
+      offset = newsz - 2;
 
       /* Allocate space for additional element. */
       if (cur_environ () == lastenviron)
This page took 0.102794 seconds and 5 git commands to generate.