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

  1. /*---------------------------------------------------------------------------
  2.  * filename - freemem.cas
  3.  *
  4.  * function(s)
  5.  *        freemem - frees a previously allocated DOS memory block
  6.  *--------------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #pragma inline
  18. #include <asmrules.h>
  19. #include <dos.h>
  20. #include <_io.h>
  21.  
  22. /*--------------------------------------------------------------------------*
  23.  
  24. Name            freemem - frees a previously allocated DOS memory block
  25.  
  26. Usage           int freemem(unsigned seg);
  27.  
  28. Prototype in    dos.h
  29.  
  30. Description     frees a memory block allocated by a previous call to
  31.                 allocmem.  seg is the segment address of that block.
  32.  
  33. Return value    success : 0
  34.                 else    : -1 and errno is set to
  35.  
  36.                         ENOMEM  Insufficient memory
  37.  
  38. *---------------------------------------------------------------------------*/
  39.  
  40.  
  41. int freemem(unsigned segx)
  42. {
  43. asm     mov     ah, 49h
  44. asm     mov     es, segx
  45. asm     int     21h
  46. asm     jc      freememFailed
  47.  
  48.         return(0);
  49.  
  50. freememFailed:
  51.         return __IOerror(_AX);
  52. }
  53.