Category : C Source Code
Archive   : C-ALL.ZIP
Filename : TI717.ASC

Output of file : TI717.ASC contained in archive : C-ALL.ZIP

PRODUCT : Borland C++ NUMBER : 717
DATE : September 18, 1991 PAGE : 1/1

TITLE : Getting Amount of Available Memory on the Far Heap

This function will determine how much memory is available
on the far heap.

To use this function you must put the statement:
extern unsigned long heapsize(void);
within the scope of the calling function.

The memory available on the far heap is computed by
determining the sum of the freed blocks of memory and
adding that amount to the value returned by coreleft().


unsigned long heapsize(void)
unsigned long i = 0; /* Return variable */
struct farheapinfo hi; /* Value returned from farheapwalk */
hi.ptr = NULL; /* Set the beginning of farheapwalk*/

if( farheapcheck() <= 0 ) /* Check for corrupted heap */
return (-1L);

while( farheapwalk(&hi) == _HEAPOK ) /* Walk the heap and sum
size of free blocks */
if( hi.in_use == 0 )
i += hi.size;

i += farcoreleft(); /* Check for amount of free memory from
the highest allocated block to the end
of DOS */
return i;

  3 Responses to “Category : C Source Code
Archive   : C-ALL.ZIP
Filename : TI717.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: