What happens when realloc() cannot extend a block in place ?
Answer: C
Correct answer: It allocates a new block, copies the contents and frees the old one
When there is not enough adjacent free space, realloc() obtains a fresh block, copies the existing data across, releases the old block and returns the new address. This is why the returned pointer must always be captured rather than assumed unchanged.
Please log in or register to report this question.