[comp.os.msdos.programmer] Allocating 64K memory block in Turbo C large mem model

cs106132@umbc5.umbc.edu (cs106132) (04/20/91)

   Hi,
I am trying to read a big FAT from a 320M DOS 4.0 partition.  It is about
80K bytes.  I would like to read it in two chunks as follows:

    unsigned int *FAT_buf1, *FAT_buf2;

    if (BIG_FAT) {  /* larger than 64K */
       if ((FAT_buf1 = (unsigned int*) malloc (64L * 1024L)) == NULL) {
          cprintf (" cannot allocate buffer for FAT\r\n");
          return (-1);
       }
       if ((FAT_buf2 = (unsigned int*) malloc (BYTES_PER_FAT-(64L*1024L))) == NULL) {
          cprintf (" cannot allocate buffer 2 for FAT\r\n");
          return (0);
       }
    }
    else {
       if ((FAT_buf1 = (unsigned int*) malloc (BYTES_PER_FAT)) == NULL) {
          cprintf (" cannot allocate buffer for FAT\r\n");
          return (-1);
       }
   }
   return (0);

/****************************************************************/
   I am using Turbo C 2.0 large memory model to compile a program that uses
code similar to the one above.  On the big partition (320M), it bombs out
when attempting to get 64K for the first buffer.  When I check the available
memory using coreleft (), I have more than 300K.  I cannot figure out what is
going wrong here?  Could it be heap fragmentation or something like that?  I am
trying to grab the buffers as the first thing in the program so fragmentation
is not really likely.  The stack size is set to 20K, and I have about 20K
static data.  The code is less than 64K.  If anyone had a similar problem and
found a solution or know what could be wrong, please let me know.  It will be
much appreciated.

Regards
Tarkan

e-mail:  cs106132@umbc5.umbc.edu