malloc() — Reserve storage block

Format

#include <stdlib.h>

void *malloc(size_t size);

General description

The malloc() function reserves a block of storage of size bytes. Unlike the calloc() function, the content of the storage allocated is indeterminate. The storage to which the returned value points is always 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, GPR12 must contain the environment token created by the __cinit() call.

Returned value

If successful, malloc() returns a pointer to the reserved space.

If not enough storage is available, or if size was specified as 0, malloc() returns NULL.

Related Information