X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f Message-ID: <3C6CF755.CC35209E@yahoo.com> From: CBFalconer Organization: Ched Research X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp 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> <2947-Fri15Feb2002112947+0200-eliz AT is DOT elta DOT co DOT il> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 40 Date: Fri, 15 Feb 2002 11:58:27 GMT NNTP-Posting-Host: 12.90.170.75 X-Complaints-To: abuse AT worldnet DOT att DOT net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1013774307 12.90.170.75 (Fri, 15 Feb 2002 11:58:27 GMT) NNTP-Posting-Date: Fri, 15 Feb 2002 11:58:27 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Eli Zaretskii wrote: > > > 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. But that doesn't explain why the static 'firstime' control failed? That should have prevented the initial cprintf calls, and in my experiment there were no others. > > 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 ;-) The file system to receive 'write' has no more reason to be initialized at that point than does cprintf, does it? -- Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT XXXXworldnet DOT att DOT net) Available for consulting/temporary embedded and systems. (Remove "XXXX" from reply address. yahoo works unmodified) mailto:uce AT ftc DOT gov (for spambots to harvest)