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

Description:
    The calloc functions allocate space for an array of n objects, each of
    length size bytes.  Each element is initialized to 0.

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

    Function     Heap

calloc
    Depends on data model of the program

_bcalloc
    Based heap specified by seg value

_fcalloc
    Far heap (outside the default data segment)

_ncalloc
    Near heap (inside the default data segment)

    In a small data memory model, the calloc function is equivalent to the
     _ncalloc function; in a large data memory model, the calloc function is
    equivalent to the  _fcalloc function.

    A block of memory allocated should be freed using the appropriate  free
    function.

Returns:
    The calloc functions return a pointer to the start of the allocated
    memory.  The return value is NULL ( _NULLOFF for  _bcalloc) if there is
    insufficient memory available or if the value of the size argument is
    zero.

Example:
    #include <stdlib.h>

    void main()
      {
        char *buffer;

        buffer = (char *)calloc( 80, sizeof(char) );
      }

Classification:
    calloc is ANSI, _fcalloc is not ANSI, _bcalloc is not ANSI, _ncalloc is
    not ANSI

Systems:
     calloc - All, Netware

    _bcalloc - DOS/16, Windows, QNX/16, OS/2 1.x(all)
    _fcalloc - DOS/16, Windows, QNX/16, OS/2 1.x(all)
    _ncalloc - DOS, Windows, Win386, Win32, QNX, OS/2 1.x, OS/2 1.x(MT),
    OS/2-32

See Also:
    _expand Functions, free 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