[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
realloc

Change the size of an allocated block of heap memory.
Compatibility:
This function is compatible with the following targets:
Prototype:
#include <stdlib.h>
void *realloc(void *ptr, size_t size);
Parameters:
Parameters for this facility are:
Remarks:
The realloc() function changes the size of the memory block pointed to by ptr to size bytes. The size argument can have a value smaller or larger than the current size of the block ptr points to. The ptr argument should be a value assigned by the memory allocation functions calloc() and malloc().
If size is 0, the memory block pointed to by ptr is released. If ptr is a null pointer, realloc() allocates size bytes.
The old contents of the memory block are preserved in the new block if the new block is larger than the old. If the new block is smaller, the extra bytes are cut from the end of the old block.
Return:
realloc() returns a pointer to the new block if it is successful and size is greater than 0. realloc() returns a null pointer if it fails or size is 0.
See Also:
"vec_realloc"
"calloc"
"free"
"malloc"
For example of realloc() usage:
Refer to "Example of calloc() usage.".
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 16, 2000