The C function for reallocating memory previously allocated by malloc and friends. In other words, it changes the size of allocated memory.

#include <stdlib.h>

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


It returns a pointer to the new piece of memory, or NULL if it failed. If it returns NULL, ptr is unchanged, and of course, errno is set. If ptr is NULL, it returns malloc(size). If size is zero, the call is equivalent to free(ptr).

Log in or register to write something here or to contact authors.