diff options
author | davygrvy <davygrvy@noemail.net> | 2002-08-28 22:48:10 (GMT) |
---|---|---|
committer | davygrvy <davygrvy@noemail.net> | 2002-08-28 22:48:10 (GMT) |
commit | 06aefb250886df523c33ac19f396b6d127ea5022 (patch) | |
tree | 9276aaf344a0938ea3d864552a3843ba199c4540 /unix/configure.in | |
parent | 02b99c49fca44c562679649b6dc001f493cbe0f9 (diff) | |
download | tcl-06aefb250886df523c33ac19f396b6d127ea5022.zip tcl-06aefb250886df523c33ac19f396b6d127ea5022.tar.gz tcl-06aefb250886df523c33ac19f396b6d127ea5022.tar.bz2 |
* generic/tclEnv.c:
* unix/configure.in:
* win/tclWinPort.h: putenv() on some systems copies the buffer
rather than taking reference to it. This causes memory leaks
and is know to effect mswindows (msvcrt) and NetBSD 1.5.2 . This
patch tests for this behavior and turns on -DHAVE_PUTENV_THAT_COPIES=1
when approriate. Thanks to David Welton for assistance.
[Bug 414910]
* unix/configure: regen'd
FossilOrigin-Name: 2985f5f43ab809b38bee93d7d59d50ade877a031
Diffstat (limited to 'unix/configure.in')
-rw-r--r-- | unix/configure.in | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/unix/configure.in b/unix/configure.in index e141949..b1d6918 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to dnl generate the file "configure", which is run during Tcl installation dnl to configure the system for the local environment. # -# RCS: @(#) $Id: configure.in,v 1.99 2002/08/28 08:47:47 dkf Exp $ +# RCS: @(#) $Id: configure.in,v 1.100 2002/08/28 22:48:39 davygrvy Exp $ AC_INIT(../generic/tcl.h) AC_PREREQ(2.13) @@ -373,6 +373,40 @@ if test $tcl_cv_char_signed = yes; then fi #-------------------------------------------------------------------- +# Does putenv() copy or not? We need to know to avoid memory leaks. +#-------------------------------------------------------------------- + +AC_MSG_CHECKING([for a putenv() that copies the buffer]) +AC_CACHE_VAL(tcl_cv_putenv_copy, + AC_TRY_RUN([ + #include <stdlib.h> + #define OURVAR "havecopy=yes" + int main (int argc, char *argv[]) + { + char *foo, *bar; + foo = (char *)strdup(OURVAR); + putenv(foo); + strcpy((char *)(strchr(foo, '=') + 1), "no"); + bar = getenv("havecopy"); + if (!strcmp(bar, "no")) { + /* doesn't copy */ + return 0; + } else { + /* does copy */ + return 1; + } + } + ], + tcl_cv_putenv_copy=no, + tcl_cv_putenv_copy=yes, + tcl_cv_putenv_copy=no) +) +AC_MSG_RESULT($tcl_cv_putenv_copy) +if test $tcl_cv_putenv_copy = yes; then + AC_DEFINE(HAVE_PUTENV_THAT_COPIES) +fi + +#-------------------------------------------------------------------- # Check for support of nl_langinfo function #-------------------------------------------------------------------- |