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 <stdlib.h>  For ANSI compatibility (free only)
    #include <malloc.h>  Required for other function prototypes
    void free( void *ptr );
    void _bfree( __segment seg, void __based(void) *ptr );
    void _ffree( void __far  *ptr );
    void _nfree( void __near *ptr );

Description:
    When the value of the argument ptr is NULL, the free function does
    nothing otherwise, the free function deallocates the memory block
    located by the argument ptr which points to a memory block previously
    allocated through a call to the appropriate version of  calloc,  malloc
    or  realloc.  After the call, the freed block is available for
    allocation.

    Each function deallocates memory from a particular heap, as listed
    below:

    Function     Heap

free
    Depends on data model of the program

_bfree
    Based heap specified by seg value

_ffree
    Far heap (outside the default data segment)

_nfree
    Near heap (inside the default data segment)

    In a large data memory model, the free function is equivalent to the
     _ffree function; in a small data memory model, the free function is
    equivalent to the  _nfree function.

Returns:
    The free functions return no value.

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

    void main()
      {
        char *buffer;

        buffer = (char *)malloc( 80 );
        if( buffer == NULL ) {
          printf( "Unable to allocate memory\n" );
        } else {

          /* rest of code goes here */

          free( buffer );  /* deallocate buffer */
        }
      }

Classification:
    free is ANSI, _ffree is not ANSI, _bfree is not ANSI, _nfree is not ANSI

Systems:
     free - All, Netware

    _bfree - DOS/16, Windows, QNX/16, OS/2 1.x(all)
    _ffree - DOS/16, Windows, QNX/16, OS/2 1.x(all)
    _nfree - DOS, Windows, Win386, Win32, QNX, OS/2 1.x, OS/2 1.x(MT),
    OS/2-32

See Also:
    calloc Functions, _expand Functions, halloc, hfree, malloc Functions,
    _msize Functions, realloc Functions, sbrk

See Also: halloc hfree

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