delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/12/15/03:00:17

From: "Lars O. Hansen" <lars DOT o DOT hansen AT gmx DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: problem with malloc and free
Date: Sun, 15 Dec 2002 08:46:15 +0100
Organization: 1&1 Internet AG
Lines: 39
Message-ID: <athc08$l6d$1@news.online.de>
References: <000001c2a37a$59f41060$186a10ac AT citechbd DOT com> <atfimi$1fk$1 AT news DOT online DOT de> <atfirg$1j4$1 AT news DOT online DOT de> <3277-Sun15Dec2002000831+0200-eliz AT is DOT elta DOT co DOT il> <Xns92E4AF8D3E4E2asu1cornelledu AT 132 DOT 236 DOT 56 DOT 8>
NNTP-Posting-Host: p508380f8.dip0.t-ipconnect.de
X-Trace: news.online.de 1039938376 21709 80.131.128.248 (15 Dec 2002 07:46:16 GMT)
X-Complaints-To: abuse AT online DOT de
NNTP-Posting-Date: 15 Dec 2002 07:46:16 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> > Crashes inside `free' or `malloc' usually mean that your program
> > overwrites buffers allocated with `malloc' and thus destroys hidden
> > data about the heap stored by `malloc' at both ends of the buffer it
> > allocates.
> >
> > So you need to look for such bugs in your program.
>
> in fact, they are pretty easy to locate. see my earlier response to the
> OP.


ok, hopefully this is it. *thanks*.   ... Yes it might have been this. :-)


So, I did  sth. like

int *a=malloc(sizeof(int)*360);

then I can access the 360th int element by

a[359] ?

I thought [359] with non-ststic arrays addresses the 360th byte in C. (it's always taking long for
me to adapt again... (I might have done this mistake not the first time...))


A question (to Eli): after i corrected that mistake and compiled for the first time and run the
program, it crashed again. then i compiled again and it didn't crash. then I compiled many more
times to make sure and it didn't crash.
I am working in A DOS box under Win 98. Could there be some sort of caching "issue" which makes
djgpp use the not just saved file or WIndows to execute the not new compiled version but the old one
?



Lars



- Raw text -


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