home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / MMSETBLK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  1.5 KB  |  54 lines

  1. /**
  2. *
  3. * Name        mmsetblk -- Grow or shrink an allocated memory block
  4. *        (Formerly called PCSETBLK.)
  5. *
  6. * Synopsis    ercode = mmsetblk(seg,size,pnewsize);
  7. *
  8. *        int ercode      Returned DOS function error code
  9. *        unsigned seg      Segment address of memory block
  10. *        unsigned size      Requested size of the memory block
  11. *        unsigned *pnewsize Returned size of adjusted memory block.
  12. *                  This may be less than requested size.
  13. *
  14. * Description    MMSETBLK adjusts the size of the memory block whose
  15. *        segment address is specified in seg.  The block must
  16. *        have been previously allocated either by DOS or by the
  17. *        MMALLOC function.  The size (in paragraphs) of the block
  18. *        is adjusted to the value specified in size.  If a "grow"
  19. *        request is made which cannot be satisfied, the block is
  20. *        grown as large as possible and the resulting size is
  21. *        returned.
  22. *
  23. * Returns    ercode          DOS function error code
  24. *        *pnewsize      Adjusted size of the block, or (if
  25. *                  requested size was too large) the
  26. *                  largest possible size
  27. *
  28. * Version    3.0  (C)Copyright Blaise Computing Inc.  1983, 1984, 1986
  29. *
  30. **/
  31.  
  32. #include <bmemory.h>
  33. #include <butility.h>
  34.  
  35. int mmsetblk(seg,size,pnewsize)
  36. unsigned seg,size,*pnewsize;
  37. {
  38.     DOSREG dos_reg;
  39.     int ercode;
  40.  
  41.     dos_reg.ax = 0x4a00;          /* DOS function 0x4a          */
  42.     dos_reg.bx = size;
  43.     dos_reg.es = seg;
  44.     ercode     = dos(&dos_reg);
  45.     if (ercode == 8)
  46.        *pnewsize = dos_reg.bx;
  47.     else if (ercode == 0)
  48.        *pnewsize = size;
  49.     else
  50.        *pnewsize = 0;
  51.  
  52.     return(ercode);
  53. }
  54.