Mail Archives: djgpp/1997/09/30/13:55:13
> Gavin Sinclair wrote:
>
> > With malloc, I was finding that it SOMETIMES fails. That is, I'd run
> > the exact same executable several times in a row, and about half the
> > time my debugging apparatus (printing to a file) would post-humously
> > report that the pointer I had tried to allocate was 0.
> >
> > Giving up, I used new instead, and now, again about half the time, the
> > entire program fails, saying "Virtual memory exceeded by 'new'". At
> > least with malloc the program ran! (With only one side-effect, too).
You are writing out-of the bounds of some of your heap or local variables, with
it you are destroying the content of some variable that holds the size of the
block to allocate, or you are using a non-initialized variable as the size of
the block to allocate.
Problems like this are hard to track. you can try using some code like MSS
(http://zipi.fi.upm.es/~a920101/mss/mss.html) to find the problem.
SET
------------------------------------ 0 --------------------------------
Visit my home page: http://www.geocities.com/SiliconValley/Vista/6552/
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Alternative e-mail: set-sot AT usa DOT net - ICQ: 2951574
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(541) 759 0013
- Raw text -