home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / FCORELFT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  1.8 KB  |  55 lines

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