reading the downloaded bcb6 help...
"Note that the string given to putenv must be static or global.
Unpredictable results will occur if a local or dynamic string given to
putenv is used after the string memory is released."
wondering, do you have to use a DIFFERENT static/global variable for EACH
environment variable that you may wish to set/modify in the environment, and
leave them untouched for the 'put'ted items to remain valid????
> "Note that the string given to putenv must be static or
> global. Unpredictable results will occur if a local or dynamic
> string given to putenv is used after the string memory is released."
>
> wondering, do you have to use a DIFFERENT static/global variable for
> EACH environment variable that you may wish to set/modify in the
> environment, and leave them untouched for the 'put'ted items to
> remain valid????
Yes.
The putenv man page on my Linux box contains this paragraph:
The putenv() function adds or changes the value of environment vari-
ables. The argument string is of the form name=value. If name does
not already exist in the environment, then string is added to the
environment. If name does exist, then the value of name in the envi-
ronment is changed to value. The string pointed to by string becomes
part of the environment, so altering the string changes the environ-
ment.
Note the last sentence.
> The putenv man page on my Linux box contains this paragraph:
Don't trust other implementations too much ;-)
Even if the standard* says the same, it's not necessarily true everywhere,
e.g. all the *BSD's works differently.
* http://www.opengroup.org/onlinepubs/009695399/functions/putenv.html
>> The putenv man page on my Linux box contains this paragraph:
>
> Don't trust other implementations too much ;-)
True.
On the other hand, putenv() is part of the POSIX Standard, i.e. it can
be used in portable code if the client code doesn't make wrong
assumptions.
> Even if the standard* says the same, it's not necessarily true everywhere,
> e.g. all the *BSD's works differently.
>
> * http://www.opengroup.org/onlinepubs/009695399/functions/putenv.html
Not regarding the OP's question:
"the string pointed to by string shall become part of the environment,
so altering the string shall change the environment"