Declaration:
void *realloc(void * ptr,
size_t size);
Attempts to resize the memory block pointed to by ptr
that was previously allocated with a call to malloc
or calloc . The contents pointed to by ptr
are unchanged. If the value of size is greater than the
previous size of the block, then the additional bytes have an
undeterminate value. If the value of size is less than
the previous size of the block, then the difference of bytes at
the end of the block are freed. If ptr is null, then it behaves
like malloc . If ptr points to a
memory block that was not allocated with calloc
or malloc , or is a space that has been
deallocated, then the result is undefined. If the new space
cannot be allocated, then the contents pointed to by ptr
are unchanged. If size is zero, then the memory block is
completely freed.
On success a pointer to the memory block is returned (which
may be in a different location as before). On failure or if size
is zero, a null pointer is returned.
|