Note, this question is not asking if realloc()
invalidates pointers within the original block, but if it invalidates all the other pointers.
I am a bit confused about the nature of realloc()
, specifically if it moves any other memory.
For example:
void* ptr1 = malloc(2);
void* ptr2 = malloc(2);
....
ptr1 = realloc(ptr1, 3);
After this, can I guarantee that ptr2
points to the same data it did before the realloc()
call?