Summary: Memory Management Functions (cont)
void *realloc(void *ptr, size_t nbytes)
- aim: increase the size of an array
- allocates a memory block of size
nbytes bytes
- if successful, copies all data from
*ptr object into it
- after copying, performs
free(ptr)
- assumes that
nbytes is larger than size of *ptr object
- if insufficient memory, returns
NULL and does not free
|