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 16:48:08 +0300 From: Eli Zaretskii Subject: Re: Different memory allocations were to the same location In-reply-to: X-012-Sender: halo1 AT inter DOT net DOT il To: djgpp AT delorie DOT com Message-id: <83y61hd7xj.fsf@gnu.org> References: 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 Precedence: bulk > From: Mok-Kong Shen > Date: Sat, 04 Jun 2011 15:02:58 +0200 > Bytes: 1846 > > I wrote a function to allocate memory to arrays of integers. But > it turns out that the the momory allocated was always at the same > location. What had I done improperly and how could I get around > the problem? (I use version 2 of the compiler.) 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?