If the area pointed to was moved, a free(ptr) is done.
Can you please explain the above line about realloc()
? This line is from a man page for calloc, malloc, realloc and free.
I think this explains it better:
If sufficient space does not exist to expand the current block in its current location, a new block of the size for size is allocated, and existing data is copied from the old block to the beginning of the new block. The old block is freed, and the function returns a pointer to the new block.
Reference taken from realloc in C
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With