Changeset 25478

Show
Ignore:
Timestamp:
05/12/08 16:48:03 (6 months ago)
Author:
bonefish
Message:

* unsetenv() was moving too much memory, thus corrupting the data after

its allocation.

* Added TODO to use a benaphore.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/src/system/libroot/posix/stdlib/env.c

    r21715 r25478  
    2424 
    2525 
     26// TODO: Use benaphore! 
    2627static sem_id sEnvLock; 
    2728static bool sCopied; 
     
    213214        env = find_variable(name, length, &index); 
    214215        if (env != NULL) { 
    215                 // we don't free the memory for the slot, we just move the array contents 
     216                // we don't free the memory for the slot, we just move the array 
     217                // contents 
    216218                free(env); 
    217                 memmove(environ + index, environ + index + 1, sizeof(char *) * (count_variables() + 1)); 
     219                memmove(environ + index, environ + index + 1, 
     220                        sizeof(char *) * (count_variables() - index)); 
    218221        } 
    219222