Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!elroy.jpl.nasa.gov!usc!alhena.usc.edu!ajayshah From: ajayshah@alhena.usc.edu (Ajay Shah) Newsgroups: comp.lang.c Subject: Found a TC 2.0 bug... ? Message-ID: <32383@usc> Date: 28 Apr 91 07:57:21 GMT Sender: news@usc Organization: University of Southern California, Los Angeles, CA Lines: 53 Nntp-Posting-Host: alhena.usc.edu Originator: ajayshah@alhena.usc.edu I think I have identified a bug in TC 2.0. My machine has 645k of free memory. I bring up the TC environment (not using tcc here). I've set the memory model to be Huge. I run this program: --------------------------------------------------------------------------- 1 #include 2 #include 3 void 4 main() 5 { 6 int i; 7 char *ptr; 8 ptr = (char *)malloc((unsigned) 0); 9 for (i=1;i<=1024;i+=i){ 10 ptr = (char *)realloc(ptr,(unsigned)i*1024); 11 if (ptr == (char *)NULL) printf("realloc bombed when "); 12 printf("%d Kbytes realloced\n",i); 13 } 14 } 15 --------------------------------------------------------------------------- I get this output: --------------------------------------------------------------------------- 1 Kbytes realloced 2 Kbytes realloced 4 Kbytes realloced 8 Kbytes realloced 16 Kbytes realloced 32 Kbytes realloced realloc bombed when 64 Kbytes realloced realloc bombed when 128 Kbytes realloced realloc bombed when 256 Kbytes realloced realloc bombed when 512 Kbytes realloced realloc bombed when 1024 Kbytes realloced --------------------------------------------------------------------------- Question: why does he have problems allocating > 64k??? Is the culprit Intel or Borland? Now watch. Instead of taking RAM in steps of 1024 bytes, I use steps of 1000 bytes. Ie., I change line 10 to be ptr = (char *)realloc(ptr,(unsigned)i*1000); Now it works!! It goes ahead and reallocs me 1Meg without complaining! There's no way I can have this kind of free RAM on a 8086!! -- _______________________________________________________________________________ Ajay Shah, (213)734-3930, ajayshah@usc.edu The more things change, the more they stay insane. _______________________________________________________________________________