My name is Michal and I live in Poland. I’ve found this forum while trying to get the information on how to reallocate a 2-d array and I’ve come across a thread which was concerned over 6 years ago on this forums. I hope you forgive me for coming back to it but I found there something which I find quite strange.
The link is: How to Realloc 2-D array
My question concerns the last post (by Salem) in this thread who wrote it in response to a piece of code posted by wots-guge in the post right above it. Salem wrote that there was a mistake in this code as the temp pointer “K2”, used to secure the outcome of realloc functions, points to the same locating that “K1” is pointing and therefore the poster’s “effort to avoid stamping on the old pointer fails”. I hope you can find that.
My question is: Is it really a mistake? As I see it, even if two pointers (in this case ‘K1’ and ‘K2’) point to the same location and the latter’s value is changed it doesn’t affect the former nor the location to which it points, therefore there is no problem using the same temp pointer a couple of times in order to assume the result of realloc functions.
Am I right or am I mixing something? Please, tell me if I don’t understand something and. I hope you don’t mind my refreshing a long forgotten thread but this issue really bothers me.
Thanks you, Michal