* Instead of just deleting the array, we have to delete its contents, too.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26720 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-08-01 15:08:06 +00:00
parent cc6c784ae7
commit 06b4c67fa5

View File

@ -46,6 +46,23 @@ unlock_variables(void)
} }
static void
free_variables(void)
{
int32 i;
if (sManagedEnviron == NULL)
return;
for (i = 0; sManagedEnviron[i] != NULL; i++) {
free(sManagedEnviron[i]);
}
free(sManagedEnviron);
sManagedEnviron = NULL;
}
static int32 static int32
count_variables(void) count_variables(void)
{ {
@ -108,7 +125,7 @@ copy_environ_to_heap_if_needed(void)
if (sManagedEnviron != NULL) { if (sManagedEnviron != NULL) {
// free previously used "environ"; it has been changed by an application // free previously used "environ"; it has been changed by an application
free(sManagedEnviron); free_variables();
} }
sManagedEnviron = malloc((count_variables() + 1) * sizeof(char *)); sManagedEnviron = malloc((count_variables() + 1) * sizeof(char *));
@ -201,8 +218,8 @@ clearenv(void)
{ {
lock_variables(); lock_variables();
free(sManagedEnviron); free_variables();
sManagedEnviron = environ = NULL; environ = NULL;
unlock_variables(); unlock_variables();
} }