home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC1.ZIP / SETBLOCK.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  1.6 KB  |  61 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - setblock.cas
  3.  *
  4.  * function(s)
  5.  *        setblock - modifies the size of a previously allocated
  6.  *                   DOS memory segment
  7.  *-----------------------------------------------------------------------*/
  8.  
  9. /*
  10.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1987, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #pragma inline
  19. #include <asmrules.h>
  20. #include <dos.h>
  21. #include <_io.h>
  22.  
  23.  
  24. /*-----------------------------------------------------------------------*
  25.  
  26. Name            setblock - modifies the size of a previously allocated
  27.                            DOS memory segment
  28.  
  29. Usage           int setblock(unsigned segx, unsigned newsize);
  30.  
  31. Prototype in    dos.h
  32.  
  33. Description     modifies the size of a memory segment.  segx is the
  34.                 segment address returned by a previous call to
  35.                 allocmem.  newsize is the new, requested size in
  36.                 paragraphs.
  37.  
  38. Return Value    returns -1 on success.  In the event of an error,
  39.                 the size of the largest possible block is returned and
  40.                 errno is set to:
  41.  
  42.                         ENOMEM  Not enough core
  43.  
  44. *------------------------------------------------------------------------*/
  45. int setblock(unsigned segx, unsigned newsize)
  46. {
  47. asm     mov     ah, 4ah
  48. asm     mov     bx, newsize
  49. asm     mov     es, segx
  50. asm     int     21h
  51. asm     jc      setblockFailed
  52.         return(-1);
  53.  
  54. setblockFailed:
  55. asm     push    bx
  56.         __IOerror(_AX);
  57. asm     pop     ax
  58.         return (_AX);
  59. }
  60.  
  61.