home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / doslynx / src / theapvie.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  1.5 KB  |  57 lines

  1. //    Copyright (c) 1993, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        THeapView
  4. //    Include File:    THeapView.H
  5. //    Purpose:    Display amount of remaining heap memory
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        12-13-93    created
  9. //        02-10-94    Split all members into seperate files.
  10. #include"theapview.h"
  11. #include"tcapture.h"
  12. #include<alloc.h>
  13. #include<strstrea.h>
  14. #include<string.h>
  15. #include<iomanip.h>
  16.  
  17. long THeapView::GetHeapSize()    {
  18. //    Purpose:    Return the free heap size
  19. //    Arguments:    void
  20. //    Return Value:    long    the free heap size
  21. //    Remarks/Portability/Dependencies/Restrictions:
  22. //    Revision History:
  23. //        12-13-93    created
  24.  
  25.     //    get a total on free far memory
  26.     long total = farcoreleft();
  27.     struct farheapinfo heap;
  28.     ostrstream totalStr(HeapInAscii, sizeof(HeapInAscii));
  29.  
  30.     //    switch and print an return the appropriate value.
  31.     //    Note an ascii message correlating to the return value is
  32.     //    put in the data member HeapInAscii.
  33.     switch(farheapcheck())    {
  34.     case _HEAPEMPTY:
  35.         strcpy(HeapInAscii, "     No heap");
  36.         total = -1L;
  37.         break;
  38.     case _HEAPCORRUPT:
  39.         if(B_tolduser == False)    {
  40.             doslynxmessage("Heap found to be corrupt.");
  41.             doslynxmessage("Consider leaving the application.");
  42.             B_tolduser = True;
  43.         }
  44.         strcpy(HeapInAscii, "Heap corrupt");
  45.         total = -2L;
  46.         break;
  47.     case _HEAPOK:
  48.         heap.ptr = NULL;
  49.         while(farheapwalk(&heap) != _HEAPEND)
  50.             if(!heap.in_use)
  51.                 total += heap.size;
  52.         totalStr << setw(12) << total << ends;
  53.         break;
  54.     }
  55.  
  56.     return(total);
  57. }