Skip to content

stdlib.h

Methods

Return Method
void* malloc( size_t size )
void* calloc( size_t n_items, size_t size )
void* realloc( void *ptr, size_t size )
void free( void *ptr )

Method Descriptions

void *malloc( size_t size )
a.k.a. memory allocation

Dynamically allocates a single block of contiguous memory according to size, containing garbage.

Returns a void pointer pointing to the first byte of allocated memory, otherwise it returns NULL if unsuccessful.


void *calloc( size_t n_items, size_t size )
a.k.a. clear allocation

Dynamically allocates multiple blocks of memory by n_items blocks sized according to size, containing zeroes.

Returns a void pointer pointing to the first byte of allocated memory, otherwise it returns NULL if unsuccessful.


void *realloc( void *ptr, size_t size )
a.k.a. reallocation

Attempts to change the size of the memory block by size, pointed to by ptr. Newly allocated bytes are not initialized.

Returns a void pointer pointing to the first byte of newly allocated memory, otherwise it returns NULL if unsuccessful.


void free( void *ptr )
Deallocates the memory previously allocated by a call to calloc, malloc, or realloc.