10.3. Memory Management Functions

The order and contiguity of storage allocated by calloc, malloc, and realloc functions is not specified.

10.3.1. The calloc function

Synopsis
#include <stdlib.h>

void *calloc (size_t nmemb , size_t size );

Description

The calloc function allocates space for an array of nmemb objects, each of whose size is size. The space is initialized to all bits zero.

Returns

The calloc function returns either a null pointer or a pointer to the allocated space.

See Also

Section 10.3.2

Section 10.3.3

Section 10.3.4

Implementation Notes

10.3.2. The free function

Synopsis
#include <stdlib.h>

void free (void * ptr );

Description

The free function causes the space pointed to by ptr to be deallocated that is, made available for further allocation.

Returns

The free function returns no value.

See Also

Section 10.3.1

Section 10.3.3

Section 10.3.4

Implementation Notes

None.

10.3.3. The malloc function

Synopsis
#include <stdlib.h>

void *malloc (size_t size );

Description

The malloc function allocates space for an object whose size is specified by size and whose value is indeterminate

Returns

The malloc function returns either a null pointer o a pointer to the allocated space.

See Also

Section 10.3.1

Section 10.3.2

Section 10.3.4

Implementation Notes

10.3.4. The realloc function

Synopsis
#include <stdlib.h>

void *realloc (void * ptr , size_t size );

Description

The realloc function allocates space for an object whose size is specified by size and whose value is indeterminate

Returns

The realloc function returns either a null pointer o a pointer to the allocated space.

See Also

Section 10.3.1

Section 10.3.2

Section 10.3.3

Implementation Notes