ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2011/06/04/10:25:00

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Date: Sat, 04 Jun 2011 17:24:46 +0300
From: Eli Zaretskii <eliz AT gnu DOT org>
Subject: Re: Different memory allocations were to the same location
In-reply-to: <isddd8$h1k$1@news.albasani.net>
X-012-Sender: halo1 AT inter DOT net DOT il
To: djgpp AT delorie DOT com
Message-id: <83wrh1d68h.fsf@gnu.org>
References: <isdadm$amb$1 AT news DOT albasani DOT net> <83y61hd7xj DOT fsf AT gnu DOT org> <isddd8$h1k$1 AT news DOT albasani DOT net>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: Mok-Kong Shen <mok-kong DOT shen AT t-online DOT de>
> Date: Sat, 04 Jun 2011 15:53:56 +0200
> Bytes: 1681
> 
> Am 04.06.2011 15:48, schrieb Eli Zaretskii:
> 
> > In generateintvec, you free the memory allocated by the previous call,
> > so the same address is now available for reuse.  Therefore calloc
> > happily reuses it.
> >
> > Why is that a problem?
> 
> But it should free the memory of that varialbe reprensented by the
> formal parameter at the time of function call, shouldn't it? (In the
> two calls uh was associated to different actual parameters.)

C passes variables by value, so the original allocation is not
affected.  You must pass a pointer to a value be able to modify that
value.

- Raw text -


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