realloc

Syntax:

    #include <cstdlib>
    void *realloc( void *ptr, size_t size );

The realloc() function changes the size of the object pointed to by ptr to the given size. size can be any size, larger or smaller than the original. The return value is a pointer to the new space, or NULL if there is an error. On failure the original memory block is not freed or moved. If ptr is NULL, realloc() acts just like malloc, creating a new memory space and returning the pointer to that new location.

Related Topics: calloc, free, malloc