What will happen with old memory block place?
This question was not yet answered. The answer is simple, it is easy to check in your code. In my case, when realloc
returns the same address (usually if I reduce the block size), calling free
with old address produce no error, which is true since it is also a new address. When it returns different address, calling free
with old address fails.
So, it does free the old block when it is reallocated:
void* location = realloc(arr, NEW_SIZE);
// do not delete arr, it points to the same or freed block