setenv vs. putenv and malloc requirements
I know that using putenv() to set an environment variable requires that the string passed into putenv must be static, or malloced because it just sets a pointer to it in the environment.
What I am not clear on is if the same is true for setenv(). The linux man and info pages don't say specifically that I must malloc the memory myself, but it doesn't say that it does it for me either.
Would it be safe to set an environment variable with setenv using a string that is just on the stack and will go away at the end or a function? I know this is a no-no with putenv.
Does anyone know?
Thanks,
John
|