Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI705.ASC

 
Output of file : TI705.ASC contained in archive : BCPPTECH.ZIP







PRODUCT : Borland C++ NUMBER : 705
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 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 : February 25, 1992 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;
}








































  3 Responses to “Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI705.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/