calloc() — Reserve and initialize storage

Format

#include <stdlib.h>

void *calloc(size_t num, size_t size);

General description

The calloc() function reserves storage space for an array of num elements, each of length size bytes. The calloc() function then gives all the bits of each element an initial value of 0.

The calloc() function returns a pointer to the reserved space. The storage space to which the returned value points is aligned for storage of any type of object.

Note: Use of this function requires that an environment has been set up through the __cinit() function. When the function is called, GPR 12 must contain the environment token created by the __cinit() call.

Returned value

If successful, calloc() returns the pointer to the area of memory reserved.

If there is not enough space to satisfy the request or if num or size is 0, calloc() returns NULL.

Related Information