When reallocating memory, if any other pointer points to same piece of memory, do I have to readjust these other pointers or do they get readjusted automatically?
When reallocating memory, if any other pointer points to same piece of memory, do I have to readjust these other pointers or do they get readjusted automatically?
No, they'll still point to the start of the block of memory, ie you don't have to touch them. http://www.opengroup.org/onlinepubs/...h/realloc.html
Originally Posted by http://www.opengroup.org/onlinepubs/007908775/xsh/realloc.html
Last edited by zacs7; 06-17-2007 at 04:36 AM.
Please clarify, i m in doubt
You will have to readjust ALL the pointers following realloc, since realloc can actually move the memory to somewhere else.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.