realloc
Reallocates a block of memory
#include <nwmalloc.h> #include <stdlib.h> void *realloc ( void *oldBlk, size_t size);
realloc returns a pointer to the start of the reallocated memory. The return value is NULL if there is insufficient memory available or if the requested size is 0.
The realloc function calls the malloc function to enlarge a block of memory.
Memory allocation is not limited to 64 KB. The size parameter is 32 bits.
When the value of the oldBlk parameter is NULL, a new block of memory of size bytes is allocated. Otherwise, the realloc function reallocates space of an object of size bytes by either:
Because it is possible that a new block can be allocated, no other pointers should point into the memory of oldBlk. When a new block is allocated, these pointers point to freed memory, with possibly disastrous results.
#include <nwmalloc.h> #include <stdlib.h> main () { char *memoryPointer; char *oldBlk; size_t size; memoryPointer = realloc (oldBlk, size); }