www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/02/14/22:15:19

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Message-ID: <3C6C735D.A6D16719@yahoo.com>
From: CBFalconer <cbfalconer AT yahoo DOT com>
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: <Pine DOT SUN DOT 3 DOT 91 DOT 1020214175634 DOT 1382J-100000 AT is>
Lines: 73
Date: Fri, 15 Feb 2002 03:09:18 GMT
NNTP-Posting-Host: 12.90.173.248
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc05-news.ops.worldnet.att.net 1013742558 12.90.173.248 (Fri, 15 Feb 2002 03:09:18 GMT)
NNTP-Posting-Date: Fri, 15 Feb 2002 03:09:18 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:
> 
> On Thu, 14 Feb 2002, CBFalconer wrote:
> 
> > cprintf avoids the blowups, but seems to pay no attention to
> > '\n'.  The output has line feeds, without <cr>.
> 
> That's normal behavior: the \n -> CR-LF conversion only happens for file
> I/O.  With direct screen I/O, you need to put the \r there explicitly.
> 
> > Using it also brings in a long startup delay.
> 
> It shouldn't, but perhaps leave this alone for now (debugging more than
> one problem at once is not a good idea ;-).
> 
> > I changed the output strings to terminate in \r\n, and now I get
> > bright patches of blue on the screen, with no output!
> 
> Does your program call some conio functions to set the screen colors?  If
> not, you should have see the normal white on black output from cprintf.
> 
> Can you show the fragment which calls cprintf?

These are the only locations enabled (with DEBUG1).  I took the
\r's out again so it doesn't destroy the screen now.

#include <conio.h>    /* cprintf for DEBUG only */
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
.......
#define DEBUG1 1       /* sbrk calls only */
.......
   /* All else failed, get more from system */
   chunk_size = size + 16;   /* two ends plus two placeholders */
   rv = (BLOCK *)sbrk(chunk_size);
   if (rv == (BLOCK *)(-1))      return 0;   /* none available */
#if DEBUG1
   cprintf("sbrk(%d) -> %p, expected %p\n",
           chunk_size, rv, expected_sbrk);
#endif
   if (rv == expected_sbrk) {
      expected_sbrk = (BLOCK *)((char *)rv + chunk_size);
      /* absorb old end-block-marker */
#if DEBUG1
      cprintf("  got expected sbrk\n");
#endif
      rv = (BLOCK *)((char *)rv - 4);
   }
   else {
      expected_sbrk = (BLOCK *)((char *)rv + chunk_size);
#if DEBUG1
      cprintf("    disconnected sbrk\n");
#endif
      /* build start-block-marker */
      rv->size = 1;
      rv = (BLOCK *)((char *)rv + 4);
      chunk_size -= 8;
   }
   rv->size = chunk_size - 8;
   ENDSZ(rv) = rv->size;
   AFTER(rv)->size = 1;
   CHECK(rv);

   RET(rv);
} /* malloc */

-- 
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)

- Raw text -


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