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" 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: <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 Precedence: bulk > From: CBFalconer > 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 ;-)