calloc()

allocate space for array 

Function


SYNOPSIS

#include <stdlib.h>

void *calloc(size_t nelem, size_t elsize);


DESCRIPTION

The calloc() function allocates space for an array of nelem elements of size elsize. The space is initialized to zero.


PARAMETERS

nelem 

Is the number of elements. If nelem is zero (0), a unique pointer to the heap is returned.

elsize 

Is the size of each element. If elsize is zero (0), a unique pointer to the heap is returned.


RETURN VALUES

If successful, calloc() returns a pointer to space suitably aligned for storage of any type of object. If there is no available memory, it returns a null pointer.


CONFORMANCE

ANSI/ISO 9899-1990.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

The calloc() function allocates from a private heap. Do not mix with Win32 heap allocation functions. Memory allocated with calloc() should only be freed with free().

Unlike many UNIX platforms, the heap that is used by malloc(), calloc() and realloc() is not guaranteed to be one contiguous piece of memory. Thus it is invalid to assume that all memory between two pointers returned by these functions is accessible, and it is invalid to compare pointers returned by these functions to determine the total size of the heap.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
free(), malloc(), memalign(), realloc(), valloc()


PTC MKS Toolkit 10.5 Documentation Build 40.