home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / SETBLOCK.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  1.9 KB  |  62 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. /*|                                                              |*/
  11. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  12. /*|                                                              |*/
  13. /*|                                                              |*/
  14. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  15. /*|     All Rights Reserved.                                     |*/
  16. /*|                                                              |*/
  17. /*[]------------------------------------------------------------[]*/
  18.  
  19. #pragma inline
  20. #include <asmrules.h>
  21. #include <dos.h>
  22. #include <_io.h>
  23.  
  24.  
  25. /*-----------------------------------------------------------------------*
  26.  
  27. Name        setblock - modifies the size of a previously allocated
  28.                DOS memory segment
  29.  
  30. Usage        int setblock(unsigned segx, unsigned newsize);
  31.  
  32. Prototype in    dos.h
  33.  
  34. Description    modifies the size of a memory segment.    segx is the
  35.         segment address returned by a previous call to
  36.         allocmem.  newsize is the new, requested size in
  37.         paragraphs.
  38.  
  39. Return Value    returns -1 on success.    In the event of an error,
  40.         the size of the largest possible block is returned and
  41.         errno is set to:
  42.  
  43.             ENOMEM    Not enough core
  44.  
  45. *------------------------------------------------------------------------*/
  46. int setblock(unsigned segx, unsigned newsize)
  47. {
  48. asm    mov    ah, 4ah
  49. asm    mov    bx, newsize
  50. asm    mov    es, segx
  51. asm    int    21h
  52. asm    jc    setblockFailed
  53.     return(-1);
  54.  
  55. setblockFailed:
  56. asm    push    bx
  57.     __IOerror(_AX);
  58. asm    pop    ax
  59.     return (_AX);
  60. }
  61.  
  62.