On Thu, Sep 30, 2010 at 02:11:19PM +0100, Matthias Scheler wrote: > On Thu, Sep 30, 2010 at 03:05:26PM +0200, Nicolas Joly wrote: > > One possibility could be to not free memory at all in setenv, but only > > with unsetenv. > > I'm not convinced about that. > > > IMHO, it's a programmer error to call setenv more than once on the > > same variable without a corresponding unsetenv in between (just like > > malloc()/free() behaviour). > > Is there any standard which backs this statement?
Not that i know. > > Otherwise, if i understand things > > correctly, it's more putenv that shoud work that way. > > Our putenv(3) is implemented via setenv(3). That may be part of the problem (at least for zsh 4.2). http://www.opengroup.org/onlinepubs/009695399/functions/putenv.html >From the OpenGroup function description; this function does not copy the provided string, but use it directly instead. It's the caller responsability to clean it when not in use anymore. zsh 4.2 seems to follow this and try to deallocate the previous variable string when it has been replaced by a new one. But our putenv, which calls setenv, has already done the same ... -- Nicolas Joly Biological Software and Databanks. Institut Pasteur, Paris.