Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <dos.h>
    #if defined(__NT__) || \
      ( defined(__OS2__) && \
            (defined(__386__) || defined(__PPC__)) )
    unsigned _dos_freemem( void *   segment );
    #else
    unsigned _dos_freemem( unsigned segment );
    #endif

Description:
    The _dos_freemem function uses system call 0x49 to release memory that
    was previously allocated by  _dos_allocmem.  The value contained in
    segment is the one returned by a previous call to  _dos_allocmem.

Returns:
    The _dos_freemem function returns zero if successful.  Otherwise, it
    returns an MS-DOS error code and sets  errno to  ENOMEM indicating a bad
    segment value or DOS memory has been corrupted.

Example:
    #include <stdio.h>
    #include <dos.h>

    void main()
      {
    #if defined(__NT__) || \
      ( defined(__OS2__) && \
            (defined(__386__) || defined(__PPC__)) )
        void *segment;
    #else
        unsigned short segment;
    #endif

        /* Try to allocate 100 paragraphs, then free them */
        if( _dos_allocmem( 100, &segment ) != 0 ) {
          printf( "_dos_allocmem failed\n" );
          printf( "Only %u paragraphs available\n",
                   segment );
        } else {
          printf( "_dos_allocmem succeeded\n" );
          if( _dos_freemem( segment ) != 0 ) {
            printf( "_dos_freemem failed\n" );
          } else {
            printf( "_dos_freemem succeeded\n" );
          }
        }
      }

Classification:
    DOS

Systems:
    DOS, Win32, OS/2 1.x(all), OS/2-32, DOS/PM

See Also:
    _dos_allocmem, _dos_setblock, free, hfree

See Also: _dos_allocmem _dos_setblock

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson