Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2018-06-06 18:45:54 +0300
committerCorinna Vinschen <corinna@vinschen.de>2018-06-07 10:42:36 +0300
commit1ecbb8d7b796b980db120d81f625d206c6a728da (patch)
tree005d4df7abd1093a81615a6431cf8b931222a064 /winsup/cygwin/environ.cc
parenta7c23d109f2e7d7fed5e1453b47ad6b384a726aa (diff)
Cygwin: Clarify some code in environ.cc
Diffstat (limited to 'winsup/cygwin/environ.cc')
-rw-r--r--winsup/cygwin/environ.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 43225341c..b452d21a5 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -545,6 +545,7 @@ _getenv_r (struct _reent *, const char *name)
return findenv_func (name, &offset);
}
+/* Return size of environment block, including terminating NULL. */
static int __stdcall
envsize (const char * const *in_envp)
{
@@ -582,11 +583,16 @@ _addenv (const char *name, const char *value, int overwrite)
else
{ /* Create new slot. */
int sz = envsize (cur_environ ());
+
+ /* Allocate space for two new slots even though only one is needed.
+ According to the commit message for commit ebd645e
+ (2001-10-03), this is done to "work around problems with some
+ buggy applications." */
int allocsz = sz + (2 * sizeof (char *));
offset = (sz - 1) / sizeof (char *);
- /* Allocate space for additional element plus terminating NULL. */
+ /* Allocate space for additional element. */
if (cur_environ () == lastenviron)
lastenviron = __cygwin_environ = (char **) realloc (cur_environ (),
allocsz);