Subject: RE: memory leak in setenv()?
From: "Andrej Borsenkow" <[email-masked]>
To: "cygwin" <[email-masked]>
Cc: <[email-masked]>
Date: Tue, 25 Jul 2000 14:37:22 +0400

> -----Original Message-----
> From: [email-masked]
> [mailto:[email-masked]]On Behalf Of Corinna Vinschen
> Sent: Tuesday, July 25, 2000 2:28 PM
> To: Andrej Borsenkow
> Cc: [email-masked]
> Subject: Re: memory leak in setenv()?
>
>
> Andrej Borsenkow wrote:
> >
> > If existing value is longer than new, old value is simply
> overwritten.
> > But if old value is shorter, new memory chunk is allocated
> via malloc(),
> > but old one is never freed. Initially all environment strings are
> > allocated using strdup() in environ_init(), so who is
> responsible for
> > freeing unused memory in this case?
>
> Nobody in case of setenv() and unsetenv(). It's a known problem
> of the environment implementation that freeing environment
> variables is not easy. The library can't decide if a string is
> currently in use by the application.
>

Agreed. I just thought, that if Cygwin (in putenv()/setenv()) allocates
memory itself (see another mail), it should also be responsible for
freeing it. If putenv() ever will be modified to not allocate new
memory, then current behaviour is correct.

cheers

-andrej

--
Want to unsubscribe from this list?
Send a message to [email-masked]