home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / mslang / vm / src / size.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-15  |  1.1 KB  |  48 lines

  1. /***
  2. * size.c - Return size of VM block
  3. *
  4. *       Copyright (c) 1990-1992, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *       Return size of VM block
  8. *
  9. *******************************************************************************/
  10.  
  11. #include <vmm.h>
  12. #include <vmbm.h>
  13.  
  14. /***
  15. * cbSizeHbk - Return the size of a VM block
  16. *
  17. *Purpose:
  18. *       Returns the size in bytes of the supplied VM block.
  19. *
  20. *Entry:
  21. *       hbk = handle of block
  22. *
  23. *Exit:
  24. *       Size of block in bytes
  25. *
  26. *Exceptions:
  27. *
  28. *******************************************************************************/
  29.  
  30. unsigned long VMFUNC __cbSizeHbk( HBK hbk )
  31. {
  32.    PHDB phdb;
  33.  
  34.    if (!_fVmInit || (unsigned long)hbk < (unsigned long)_hbkMin || (unsigned long)hbk >= (unsigned long)_hbkMax)
  35.       return 0L;
  36.  
  37.    /* load the page with the hbk*/
  38.    phdb = __PVmLoadVp((VPVOID) hbk, FALSE);
  39.  
  40.    if (!phdb || phdb->fFree)
  41.       return 0L;
  42.  
  43.    if(phdb->fByPage)
  44.        return ((((unsigned long)phdb->cPage) * cbVmPage) - (unsigned long)sizeof(HDB));
  45.    else
  46.        return (((unsigned long)CbGetSize(phdb->cbSize)) - (unsigned long)sizeof(HDB));
  47. }
  48.