delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/07/25/06:39:47

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
X-Envelope-Sender-Is: Andrej DOT Borsenkow AT mow DOT siemens DOT ru (at relayer goliath.siemens.de)
From: "Andrej Borsenkow" <Andrej DOT Borsenkow AT mow DOT siemens DOT ru>
To: "cygwin" <cygwin AT sources DOT redhat DOT com>
Cc: <Cygwin AT Sourceware DOT Cygnus DOT Com>
Subject: RE: memory leak in setenv()?
Date: Tue, 25 Jul 2000 14:37:22 +0400
Message-ID: <001501bff624$50c24df0$21c9ca95@mow.siemens.ru>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Importance: Normal
In-reply-to: <397D6B99.77361071@cygnus.com>


> -----Original Message-----
> From: corinna AT snoopy DOT vinschen DOT de
> [mailto:corinna AT snoopy DOT vinschen DOT de]On Behalf Of Corinna Vinschen
> Sent: Tuesday, July 25, 2000 2:28 PM
> To: Andrej Borsenkow
> Cc: Cygwin AT Sourceware DOT Cygnus DOT Com
> 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 cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019