home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / MMSIZE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  1009 b   |  42 lines

  1. /**
  2. *
  3. * Name        mmsize -- Report program size.
  4. *
  5. * Synopsis    size = mmsize();
  6. *
  7. *        unsigned size      Memory size of the program in
  8. *                  paragraphs, or zero if error from MMCTRL.
  9. *
  10. * Description    This function reports the size of the memory block
  11. *        occupied by the program's code and data.  The size is
  12. *        reported in units called paragraphs, which are sixteen
  13. *        bytes long.
  14. *
  15. * Method    We inspect the memory control block that governs the
  16. *        memory block occupied by the program.
  17. *
  18. * Returns    size          Memory size of the program in
  19. *                  paragraphs, or zero if error from MMCTRL.
  20. *
  21. * Version    6.00 (C)Copyright Blaise Computing Inc. 1987, 1989
  22. *
  23. **/
  24.  
  25. #include <dos.h>              /* For use with utpspseg.       */
  26.  
  27. #include <bmem.h>
  28. #include <butil.h>
  29.  
  30. unsigned mmsize()
  31. {
  32.     MEMCTRL  ctlblock;
  33.     unsigned nextblock;
  34.     int      ercode;
  35.  
  36.     ercode = mmctrl(utpspseg,&ctlblock,&nextblock);
  37.     if (ercode == 0 || ercode == 18)
  38.     return ctlblock.size;
  39.     else
  40.     return 0;
  41. }
  42.