home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / FREEMEM.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  1.6 KB  |  55 lines

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