PRODUCT : Borland C++ NUMBER : 705 VERSION : 2.0 OS : DOS DATE : October 19, 1993 PAGE : 1/2 TITLE : Allocating More Than 64K of Memory in DOS /************************************************************************ This program demonstrates the dynamic allocation of a memory block larger than 64K bytes using farcalloc(). It should not be compiled in the Tiny memory model. The program calls farcoreleft prior to allocating the block of memory to determine how much memory is available. Note that this method will not be accurate if memory has been previously allocated and then released as the released memory is handled differently. If you choose to run this program from inside the integrated development environment you must set the head size under OPTIONS/DEBUGGER to at least the size of the two parameters passed to farcalloc() + 5 bytes. Also note that farcalloc can be interchanged freely with farmalloc or farrealloc in this example. ***********************************************************************/ #include #include #include #include #include int main(void) { int huge *fptr; unsigned long val; clrscr(); /* Check the amount of memory available if no blocks have been freed */ printf("\nMemory available on the far heap: %lu\n",val = farcoreleft()); /* allocate memory for the far pointer */ fptr = (int huge *) farcalloc( 66000L, sizeof(int)); /* display string (note the F modifier) */ printf("Address of allocated block is: %Fp", fptr); PRODUCT : Borland C++ NUMBER : 705 VERSION : 2.0 OS : DOS DATE : October 19, 1993 PAGE : 2/2 TITLE : Allocating More Than 64K of Memory in DOS /* Check how much memory is left */ printf("\nMemory left on the far heap: %lu\n",val = farcoreleft()); getch(); /* free the memory */ farfree((int far *) fptr); return 0; } DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.