Namespaces
Variants
Views
Actions

std::realloc

From cppreference.com
< cpp‎ | memory‎ | c
Revision as of 01:29, 13 June 2011 by P12 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:cpp/memory/c/sidebar

Defined in header <cstdlib>
void *realloc( void *ptr, size_t new_size );

Reallocates the given area of memory. It must be previously allocated by malloc(), calloc() or realloc(), otherwise the results are undefined.

The contents of the area remain unchanged up to the lesser of the new and old sizes. If the area is expanded, the contents of the new part of the array are undefined.

Template:params

ptr - pointer to the memory area to be reallocated
new_size - new size of the array

Template:returns

pointer to the beginning of newly allocated memory or Template:cpp if error has occurred. The pointer must be deallocated with free().