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

  1. /*---------------------------------------------------------------------------
  2.  * filename - dosfree.c
  3.  *
  4.  * function(s)
  5.  *        _dos_freemem - frees a previously allocated DOS memory block
  6.  *                       (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_freemem - frees a previously allocated DOS memory block
  24.  
  25. Usage           int _dos_freemem(unsigned seg);
  26.  
  27. Prototype in    dos.h
  28.  
  29. Description     frees a memory block allocated by a previous call to
  30.                 allocmem.  seg is the segment address of that block.
  31.  
  32. Return value    success : 0
  33.                 else    : DOS error number, and errno is set to
  34.  
  35.                         ENOMEM  Insufficient memory
  36.  
  37. Note            Compatible with Microsoft C.  Not the same as freemem().
  38.  
  39. *---------------------------------------------------------------------------*/
  40.  
  41.  
  42. unsigned _dos_freemem(unsigned segx)
  43. {
  44.     _ES = segx;
  45.     _AH = 0x49;
  46.     geninterrupt(0x21);
  47.     if (_FLAGS & 1)                     /* if carry set, error */
  48.         return (__DOSerror(_AX));       /* set errno */
  49.     else
  50.         return (0);
  51. }
  52.