made getenv() more threadsafe for win32

This commit is contained in:
Daniel Stenberg
2000-05-29 23:07:22 +00:00
parent 45885f30c2
commit 6d522c9c1d
5 changed files with 37 additions and 15 deletions

View File

@@ -39,6 +39,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#include <windows.h>
@@ -48,7 +49,7 @@ char *GetEnv(char *variable)
{
#ifdef WIN32
/* This shit requires windows.h (HUGE) to be included */
static char env[MAX_PATH]; /* MAX_PATH is from windef.h */
char env[MAX_PATH]; /* MAX_PATH is from windef.h */
char *temp = getenv(variable);
env[0] = '\0';
ExpandEnvironmentStrings(temp, env, sizeof(env));
@@ -56,7 +57,7 @@ char *GetEnv(char *variable)
/* no length control */
char *env = getenv(variable);
#endif
return env;
return env?strdup(env):NULL;
}
char *curl_GetEnv(char *v)