Article View: comp.os.msdos.programmer
Article #5862Allocating 64K memory block in Turbo C large mem model
From: cs106132
Date: Fri, 19 Apr 1991 20:53
Date: Fri, 19 Apr 1991 20:53
41 lines
2189 bytes
2189 bytes
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
Technical Details
Message-ID:
<1991Apr19.205341.16294@umbc3.umbc.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!ncar!gatech!udel!haven!umbc3.umbc.edu!umbc5.umbc.edu!cs106132Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!ncar!gatech!udel!haven!umbc3.umbc.edu!umbc5.umbc.edu!cs106132 From: cs106132@umbc5.umbc.edu (cs106132) Newsgroups: comp.os.msdos.programmer Subject: Allocating 64K memory block in Turbo C large mem model Message-ID: <1991Apr19.205341.16294@umbc3.umbc.edu> Date: 19 Apr 91 20:53:41 GMT Sender: newspost@umbc3.umbc.edu (News posting account) Distribution: usa Organization: University of Maryland Baltimore County Lines: 41 Originator: cs106132@umbc5.umbc.edu