Using environment variables without leaking memory?

Dave Dodge dododge at dododge.net
Tue Oct 31 05:56:09 UTC 2006


On Thu, Oct 26, 2006 at 04:20:14PM -0400, Rich Felker wrote:
> BTW do you know if getenv() is required to return the actual strings
> from the environment? (i.e. if getenv("HOME")-5 necessarily points to
> the "H")

It is allowed but not required.

For one thing, if it were required then there'd be no need for the
warning that calling getenv() can overwrite the previous results of
getenv().  The POSIX/SUS page on getenv() has a bunch of commentary in
the Rationale section that explains some of the decisions and possible
implementations:

  http://www.opengroup.org/onlinepubs/009695399/functions/getenv.html

                                                  -Dave Dodge



More information about the uClibc mailing list