www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/05/18:01:36

From: Neil & Joey Obremski <obremski AT nwrain DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: malloc errors
Date: Sun, 05 Apr 1998 14:01:21 +0000
Organization: CyCLONE7 Design
Lines: 32
Message-ID: <35278EB1.CDF435CC@nwrain.com>
Reply-To: obremski AT nwrain DOT com
NNTP-Posting-Host: 22008 AT 205 DOT 134 DOT 220 DOT 163
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I've had problems in some of my programs using 'new' which of course
comes out using malloc anyway.  I found this out quickly when a lot of
my programs kept crashing and gdb kept saying malloc did it ;)

I don't know if there's a problem with malloc in djgpp or not, but it
certainly doesn't work 100% correctly when I use it.  Some of my
programs I spent hours debugging only to find that if I pass a
constant added to a variable to my allocation function (Alloc I called
it, wow pretty original =) malloc works fine, otherwise it doesn't.

For example.  I was messing around with a convenient "substring" style
function that I was making.  In one part I have:

  Alloc(newlen);

This crashes the program after going past it only once or twice. 
However if I...

  Alloc(100);

It works fine.  Similarly:

  Alloc(newlen + 100);

works fine as well. !??!?!?  I have DJGPP 2.01.  Has anyone else had
this problem?

-- 
 /----------------------[nobremski AT hotmail DOT com]----------------------\
( Neil C. Obremski                                     Ashrak DeadEye
)
 \-----------------[http://www.nwrain.com/~deadeye/]-----------------/

- Raw text -


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