public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: Clarify some code in environ.cc Date: Thu, 07 Jun 2018 08:03:00 -0000 [thread overview] Message-ID: <20180607080302.99565.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=1ecbb8d7b796b980db120d81f625d206c6a728da commit 1ecbb8d7b796b980db120d81f625d206c6a728da Author: Ken Brown <kbrown@cornell.edu> Date: Wed Jun 6 11:45:54 2018 -0400 Cygwin: Clarify some code in environ.cc Diff: --- winsup/cygwin/environ.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 4322534..b452d21 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);
reply other threads:[~2018-06-07 8:03 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20180607080302.99565.qmail@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).