- Replaced HeapAlloc, HeapFree and HeapReAlloc with alloc, free and realloc.

svn path=/trunk/; revision=12091
This commit is contained in:
Hartmut Birr 2004-12-13 18:30:08 +00:00
parent e2e32b1c11
commit 1d2f603b9d

View file

@ -1,4 +1,4 @@
/* $Id: environ.c,v 1.11 2004/08/31 14:40:50 hbirr Exp $ /* $Id: environ.c,v 1.12 2004/12/13 18:30:08 hbirr Exp $
* *
* dllmain.c * dllmain.c
* *
@ -56,7 +56,7 @@ int BlockEnvToEnvironA(void)
count++; count++;
} }
_environ = HeapAlloc(GetProcessHeap(), 0, count * sizeof(char*)); _environ = malloc(count * sizeof(char*));
if (_environ) if (_environ)
{ {
for (ptr = environment_strings, envptr = _environ; count > 1; ptr += len) for (ptr = environment_strings, envptr = _environ; count > 1; ptr += len)
@ -70,7 +70,7 @@ int BlockEnvToEnvironA(void)
for (envptr--; envptr >= _environ; envptr--); for (envptr--; envptr >= _environ; envptr--);
free(*envptr); free(*envptr);
FreeEnvironmentStringsA(environment_strings); FreeEnvironmentStringsA(environment_strings);
HeapFree(GetProcessHeap(), 0, _environ); free(_environ);
return -1; return -1;
} }
memcpy(*envptr++, ptr, len); memcpy(*envptr++, ptr, len);
@ -106,7 +106,7 @@ int BlockEnvToEnvironW(void)
count++; count++;
} }
_wenviron = HeapAlloc(GetProcessHeap(), 0, count * sizeof(wchar_t*)); _wenviron = malloc(count * sizeof(wchar_t*));
if (_wenviron) if (_wenviron)
{ {
for (ptr = environment_strings, envptr = _wenviron; count > 1; ptr += len) for (ptr = environment_strings, envptr = _wenviron; count > 1; ptr += len)
@ -120,7 +120,7 @@ int BlockEnvToEnvironW(void)
for (envptr--; envptr >= _wenviron; envptr--); for (envptr--; envptr >= _wenviron; envptr--);
free(*envptr); free(*envptr);
FreeEnvironmentStringsW(environment_strings); FreeEnvironmentStringsW(environment_strings);
HeapFree(GetProcessHeap(), 0, _wenviron); free(_wenviron);
return -1; return -1;
} }
memcpy(*envptr++, ptr, len * sizeof(wchar_t)); memcpy(*envptr++, ptr, len * sizeof(wchar_t));
@ -156,7 +156,7 @@ char **DuplicateEnvironment(char **original_environment, int wide)
for (envptr = original_environment; *envptr != NULL; envptr++, count++) for (envptr = original_environment; *envptr != NULL; envptr++, count++)
; ;
newenvptr = newenv = HeapAlloc(GetProcessHeap(), 0, count * sizeof(char*)); newenvptr = newenv = malloc(count * sizeof(char*));
if (newenv == NULL) if (newenv == NULL)
return original_environment; return original_environment;
@ -170,7 +170,7 @@ char **DuplicateEnvironment(char **original_environment, int wide)
{ {
for (newenvptr--; newenvptr >= newenv; newenvptr--); for (newenvptr--; newenvptr >= newenv; newenvptr--);
free(*newenvptr); free(*newenvptr);
HeapFree(GetProcessHeap(), 0, newenv); free(newenv);
return original_environment; return original_environment;
} }
} }
@ -191,7 +191,7 @@ void FreeEnvironment(char **environment)
char **envptr; char **envptr;
for (envptr = environment; *envptr != NULL; envptr++) for (envptr = environment; *envptr != NULL; envptr++)
free(*envptr); free(*envptr);
HeapFree(GetProcessHeap(), 0, environment); free(environment);
} }
/** /**
@ -260,8 +260,7 @@ int SetEnv(const wchar_t *option)
free(*wenvptr); free(*wenvptr);
for (count = index; *wenvptr != NULL; wenvptr++, count++) for (count = index; *wenvptr != NULL; wenvptr++, count++)
*wenvptr = *(wenvptr + 1); *wenvptr = *(wenvptr + 1);
_wenviron = HeapReAlloc(GetProcessHeap(), 0, _wenviron, _wenviron = realloc(_wenviron, count * sizeof(wchar_t*));
count * sizeof(wchar_t*));
/* Remove the option from multibyte environment. We assume /* Remove the option from multibyte environment. We assume
* the environments are in sync and the option is at the * the environments are in sync and the option is at the
@ -269,8 +268,7 @@ int SetEnv(const wchar_t *option)
free(_environ[index]); free(_environ[index]);
for (; _environ[index] != NULL; index++) for (; _environ[index] != NULL; index++)
_environ[index] = _environ[index + 1]; _environ[index] = _environ[index + 1];
_environ = HeapReAlloc(GetProcessHeap(), 0, _environ, _environ = realloc(_environ, count * sizeof(char*));
count * sizeof(char*));
result = SetEnvironmentVariableW(name, NULL) ? 0 : -1; result = SetEnvironmentVariableW(name, NULL) ? 0 : -1;
} }
@ -313,8 +311,7 @@ int SetEnv(const wchar_t *option)
; ;
/* Create a new entry. */ /* Create a new entry. */
if ((wnewenv = HeapReAlloc(GetProcessHeap(), 0, _wenviron, if ((wnewenv = realloc(_wenviron, (count + 2) * sizeof(wchar_t*))) == NULL)
(count + 2) * sizeof(wchar_t*))) == NULL)
{ {
free(name); free(name);
free(mboption); free(mboption);
@ -322,8 +319,7 @@ int SetEnv(const wchar_t *option)
return -1; return -1;
} }
_wenviron = wnewenv; _wenviron = wnewenv;
if ((mbnewenv = HeapReAlloc(GetProcessHeap(), 0, _environ, if ((mbnewenv = realloc(_environ, (count + 2) * sizeof(char*))) == NULL)
(count + 2) * sizeof(char*))) == NULL)
{ {
free(name); free(name);
free(mboption); free(mboption);