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 (malloc only)
    #include <malloc.h>  Required for other function prototypes
    void *malloc( size_t size );
    void __based(void) *_bmalloc( __segment seg, size_t size );
    void __far  *_fmalloc( size_t size );
    void __near *_nmalloc( size_t size );

Description:
    The malloc functions allocate space for an object of size bytes.
     Nothing is allocated when the size argument has a value of zero.

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

    Function     Heap

malloc
    Depends on data model of the program

_bmalloc
    Based heap specified by seg value

_fmalloc
    Far heap (outside the default data segment)

_nmalloc
    Near heap (inside the default data segment)

    In a small data memory model, the malloc function is equivalent to the
     _nmalloc function; in a large data memory model, the malloc function is
    equivalent to the  _fmalloc function.

Returns:
    The malloc functions return a pointer to the start of the allocated
    memory.  The malloc,  _fmalloc and  _nmalloc functions return NULL if
    there is insufficient memory available or if the requested size is zero.
     The  _bmalloc function returns  _NULLOFF if there is insufficient
    memory available or if the requested size is zero.

Example:
    #include <stdlib.h>

    void main()
      {
        char *buffer;

        buffer = (char *)malloc( 80 );
        if( buffer != NULL ) {

            /* body of program */

            free( buffer );
        }
      }

Classification:
    malloc is ANSI, _fmalloc is not ANSI, _bmalloc is not ANSI, _nmalloc is
    not ANSI

Systems:
     malloc - All, Netware

    _bmalloc - DOS/16, Windows, QNX/16, OS/2 1.x(all)
    _fmalloc - DOS/16, Windows, QNX/16, OS/2 1.x(all)
    _nmalloc - DOS, Windows, Win386, Win32, QNX, OS/2 1.x, OS/2 1.x(MT),
    OS/2-32

See Also:
    calloc Functions, _expand Functions, free Functions, halloc, hfree,
    _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