diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-15 12:11:51 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-15 12:11:51 (GMT) |
commit | 27ee10bdf0fa2f7838073ceda95963b7e0ee71bd (patch) | |
tree | d99f0826246d4d41cab71ed69964e1baed0ba21d /generic/tclEnv.c | |
parent | ad027699337cb14f37a3914d03a1504da8d0f946 (diff) | |
parent | 13be49f5852a9f3bb1a82aa726f16322d00d38e7 (diff) | |
download | tcl-27ee10bdf0fa2f7838073ceda95963b7e0ee71bd.zip tcl-27ee10bdf0fa2f7838073ceda95963b7e0ee71bd.tar.gz tcl-27ee10bdf0fa2f7838073ceda95963b7e0ee71bd.tar.bz2 |
Merge 8.6. Also fix build with -DTCL_NO_DEPRECATED (which was also the cause of the "master" build failure)
Diffstat (limited to 'generic/tclEnv.c')
-rw-r--r-- | generic/tclEnv.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/generic/tclEnv.c b/generic/tclEnv.c index fbc641c..143dab9 100644 --- a/generic/tclEnv.c +++ b/generic/tclEnv.c @@ -17,23 +17,6 @@ TCL_DECLARE_MUTEX(envMutex) /* To serialize access to environ. */ -static struct { - int cacheSize; /* Number of env strings in cache. */ - char **cache; /* Array containing all of the environment - * strings that Tcl has allocated. */ -#ifndef USE_PUTENV - char **ourEnviron; /* Cache of the array that we allocate. We - * need to track this in case another - * subsystem swaps around the environ array - * like we do. */ - int ourEnvironSize; /* Non-zero means that the environ array was - * malloced and has this many total entries - * allocated to it (not all may be in use at - * once). Zero means that the environment - * array is in its original static state. */ -#endif -} env; - #if defined(_WIN32) # define tenviron _wenviron # define tenviron2utfdstr(string, len, dsPtr) (Tcl_DStringInit(dsPtr), \ @@ -53,6 +36,23 @@ static struct { # define techar char #endif +static struct { + int cacheSize; /* Number of env strings in cache. */ + char **cache; /* Array containing all of the environment + * strings that Tcl has allocated. */ +#ifndef USE_PUTENV + techar **ourEnviron; /* Cache of the array that we allocate. We + * need to track this in case another + * subsystem swaps around the environ array + * like we do. */ + int ourEnvironSize; /* Non-zero means that the environ array was + * malloced and has this many total entries + * allocated to it (not all may be in use at + * once). Zero means that the environment + * array is in its original static state. */ +#endif +} env; + #define tNTL sizeof(techar) /* @@ -259,14 +259,14 @@ TclSetEnv( * environment is the one we allocated. [Bug 979640] */ - if ((env.ourEnviron != (char *)tenviron) || (length+2 > env.ourEnvironSize)) { - char **newEnviron = (char **)ckalloc((length + 5) * sizeof(char *)); + if ((env.ourEnviron != tenviron) || (length+2 > env.ourEnvironSize)) { + techar **newEnviron = (techar **)ckalloc((length + 5) * sizeof(techar *)); - memcpy(newEnviron, tenviron, length * sizeof(char *)); + memcpy(newEnviron, tenviron, length * sizeof(techar *)); if ((env.ourEnvironSize != 0) && (env.ourEnviron != NULL)) { ckfree(env.ourEnviron); } - tenviron = (techar **)(env.ourEnviron = newEnviron); + tenviron = (env.ourEnviron = newEnviron); env.ourEnvironSize = length + 5; } index = length; |