home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC1.ZIP / FCORELFT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.4 KB  |  52 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - fcorelft.c
  3.  *
  4.  * function(s)
  5.  *        farcoreleft - returns measure of unused memory in far heap
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #include <alloc.h>
  18. #include <_fheap.h>
  19.  
  20. /*---------------------------------------------------------------------*
  21.  
  22. Name            farcoreleft - returns measure of unused memory in
  23.                               far heap
  24.  
  25. Usage           long farcoreleft(void);
  26.  
  27. Prototype in    alloc.h
  28.  
  29. Description     returns measure of unused memory in far heap beyond the
  30.                 highest allocated block.
  31.  
  32. Return value    see description.
  33.  
  34. *---------------------------------------------------------------------*/
  35.  
  36. /*----------------------------------------------------------------------
  37.   In protected mode we'll do a DosMemAvail, in real mode we'll ask for
  38.   an outrageous amount of memory via INT 21 and look at the BX register
  39.   on return.
  40. ----------------------------------------------------------------------*/
  41.  
  42. unsigned long farcoreleft(void)
  43.   {
  44.   unsigned long value = 0L;
  45.   value = _heaptop - _brklvl;
  46.  
  47.   if( value > 16 )  value -= 16;
  48.  
  49.   value &= 0xfffffff0L;
  50.   return( value );
  51.   }
  52.