I have a question, which arose partly out of fixing some crash bugs which brought certain things to light.
When you use new/delete, and you call delete on a class/struct/whatever, is it necessary to then NULL the pointer after calling delete?
I had a situation where stop_editing, stop_hunting, stop_fearing, and other functions of this nature were not quite finishing the job of removing the memory pointer.
In stop_editing, I had this:
delete ch->pcdata->editor;
If you used the editor once, no problem. Any attempt to use it a second time and it would crash unless I did this:
delete ch->pcdata->editor;
ch->pcdata->editor = NULL;
Now, obviously I've not done this for every last use of delete, so I'm wondering if I need to. Gotta hate how you discover this kind of thing *AFTER* you've gone through and changed almost everything to use them :P
When you use new/delete, and you call delete on a class/struct/whatever, is it necessary to then NULL the pointer after calling delete?
I had a situation where stop_editing, stop_hunting, stop_fearing, and other functions of this nature were not quite finishing the job of removing the memory pointer.
In stop_editing, I had this:
delete ch->pcdata->editor;
If you used the editor once, no problem. Any attempt to use it a second time and it would crash unless I did this:
delete ch->pcdata->editor;
ch->pcdata->editor = NULL;
Now, obviously I've not done this for every last use of delete, so I'm wondering if I need to. Gotta hate how you discover this kind of thing *AFTER* you've gone through and changed almost everything to use them :P