Using environment variables without leaking memory?

Rob Landley rob at landley.net
Tue Oct 24 19:24:55 UTC 2006


On Tuesday 24 October 2006 10:45 am, Dave Dodge wrote:
> Add threads into the mix and it just gets worse.

That statement's true for just about anything, though. :)

Luckily neither my shell, nor toybox, is multi-threaded.  (Got _that_ out of 
my system with OS/2 and Java...)

> > How do I set (and reset) environment variables without leaking memory?
> 
> The preferred API is getenv, setenv, and unsetenv.  I don't think
> there's any guarantees about them freeing memory, but their API does
> at least allow them to do so.

Cool.  Does uClibc's setenv/unsetenv free memory then?  (Rummage, rummage...)

Darn it.  That code is copied from glibc, and glibc doesn't do this.  (uClibc 
probably _could_ do this, but it doesn't because glibc didn't...)

I need to make this work myself. :(

> Other stuff gleaned from various bits of POSIX/SUS:
...

Good to know, but I can ignore the threading stuff for now. :)

Rob
-- 
"Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away." - Antoine de Saint-Exupery



More information about the uClibc mailing list