Natraj Posted November 28, 2009 Share Posted November 28, 2009 where we avoid dangling pointer? Link to comment Share on other sites More sharing options...
0 Argote Posted November 28, 2009 Share Posted November 28, 2009 Umm, could you make your post clearer? Link to comment Share on other sites More sharing options...
0 Livin in a box Posted November 28, 2009 Share Posted November 28, 2009 Dangling pointer...0_o Link to comment Share on other sites More sharing options...
0 hdood Posted November 28, 2009 Share Posted November 28, 2009 Dangling pointer...0_o It's where the memory its address points to was freed but the program keeps on using the pointer (which is now effectively pointing to random memory) anyway. The answer is to stop using it at that point, or at the very least set the pointer to NULL once the associated memory has been freed. Link to comment Share on other sites More sharing options...
0 gian Posted November 29, 2009 Share Posted November 29, 2009 It's where the memory its address points to was freed but the program keeps on using the pointer (which is now effectively pointing to random memory) anyway.The answer is to stop using it at that point, or at the very least set the pointer to NULL once the associated memory has been freed. Yeah it's ablosutely more safe to set it to NULL, nothing REALLY bad can come out from accessing a NULL pointer, you will understand your mistake right away. If however at some point later on you re-use that pointer which used to point to useful memory for your program, your program may continue to work but it may end up giving you false results and corrupting your data. Those memory problems are very sneaky, I remember a program was giving segfault on my PC but it was working "fine" on my friend's PC apparently giving wrong results (and it is not always easy to check if a result is correct) Link to comment Share on other sites More sharing options...
Question
Natraj
where we avoid dangling pointer?
Link to comment
Share on other sites
4 answers to this question
Recommended Posts