Eric Gillespie <[EMAIL PROTECTED]> writes:

> I just checked Harbison & Steele, and according to them ISO C
> does not allow calls to putenv to modify the getenv return
> value, and as seen above, nor does POSIX (though the XSI
> extension does).  Maybe i'm just not very imaginative at this
> late hour, but i don't see another way to implement the
> environment without putenv modifying it, so i find it strange
> that the two important standards don't allow for it.

Just thought of one, though perhaps not the most obvious.  POSIX
and ISO C *do* mention static buffers; a getenv implementation
can copy from the environment array into its own static buffer,
extending it if necessary (subsequent getenv buffers may
invalidate old ones, i.e. return addresses of newly allocated
buffers).  Then putenv calls wouldn't invalidate the getenv
return value.

--  
Eric Gillespie <*> [EMAIL PROTECTED]

Build a fire for a man, and he'll be warm for a day.  Set a man on
fire, and he'll be warm for the rest of his life. -Terry Pratchett

Reply via email to