www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/02/15/04:35:23

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Date: Fri, 15 Feb 2002 11:29:48 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: djgpp AT delorie DOT com
Message-Id: <2947-Fri15Feb2002112947+0200-eliz@is.elta.co.il>
X-Mailer: emacs 21.2.50 (via feedmail 8 I) and Blat ver 1.8.9
In-reply-to: <3C6CC93C.6F9E05E6@yahoo.com> (message from CBFalconer on Fri, 15
Feb 2002 08:40:10 GMT)
Subject: Re: Malloc/free DJGPP code
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1020214175634 DOT 1382J-100000 AT is> <3C6C735D DOT A6D16719 AT yahoo DOT com> <1225-Fri15Feb2002084500+0200-eliz AT is DOT elta DOT co DOT il> <3C6CC93C DOT 6F9E05E6 AT yahoo DOT com>
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: CBFalconer <cbfalconer AT yahoo DOT com>
> Newsgroups: comp.os.msdos.djgpp
> Date: Fri, 15 Feb 2002 08:40:10 GMT
> 
> I suspect the first malloc call is made before the global arena is
> setup.

No, that's not true, but it did give me a clue of what's happening:
the conio functions need initialization.  That initialization runs
from a static constructor, which is called just before `main'.  But
malloc is called before that, from the startup code, so you end up
invoking cprintf without it being properly initialized.

My bad, I should have thought about this before.

So DJ's advice, to use sprintf and then write the buffer with a call
to the function `write', is better.

> This is annoying.  If other things aren't set up, I am very leery
> of calling anything whatsoever at this point.  Who knows what is
> getting written on.

Don't give up ;-)

- Raw text -


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