home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / DOSSETBL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.9 KB  |  60 lines

  1. /*---------------------------------------------------------------------------
  2.  * filename - dossetbl.c
  3.  *
  4.  * function(s)
  5.  *        _dos_setblock - modifies the size of a previously allocated
  6.  *                   DOS memory segment (MSC compatible)
  7.  *--------------------------------------------------------------------------*/
  8.  
  9. /*
  10.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1991, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #include <dos.h>
  19. #include <_io.h>
  20.  
  21. /*--------------------------------------------------------------------------*
  22.  
  23. Name            _dos_setblock - modifies the size of a previously allocated
  24.                            DOS memory segment
  25.  
  26. Usage           unsigned setblock(unsigned size, unsigned segx,
  27.                         unsigned *maxp);
  28.  
  29. Prototype in    dos.h
  30.  
  31. Description     modifies the size of a memory segment.  segx is the
  32.                 segment address returned by a previous call to
  33.                 _dos_allocmem.  size is the new, requested size in
  34.                 paragraphs.  If the request can't be satisfied, the
  35.                 maximum possible segment size is stored at *maxp.
  36.  
  37. Return value    success : 0
  38.                 else    : DOS error number, and errno is set to
  39.  
  40.                         ENOMEM  Insufficient memory
  41.  
  42. Note            Compatible with Microsoft C.  Not the same as setblock().
  43.  
  44. *---------------------------------------------------------------------------*/
  45.  
  46. unsigned _dos_setblock(unsigned size, unsigned segx, unsigned *maxp)
  47. {
  48.     _ES = segx;
  49.     _BX = size;
  50.     _AH = 0x4a;
  51.     geninterrupt(0x21);
  52.     if (_FLAGS & 1)                     /* if carry set, error */
  53.     {
  54.         *maxp = _BX;                    /* return max. block size */
  55.         return (__DOSerror(_AX));       /* set errno */
  56.     }
  57.     else
  58.         return (0);
  59. }
  60.