* Victor Bazarov:
> Alf P. Steinbach wrote:
> > * Venn Syii:
> >
> >>I have the following line of code:
> >>
> >> if (MyData)
> >> {
> >> delete MyData;
> >> MyData= NULL;
> >> }
> >
> >
> > It suffices to write
> >
> >
> > delete MyData;
>
> No, it does not. Setting a pointer to NULL after deletion prevents any
> further double deletions of the same memory.
Well, we could argue about that.
I've taken both sides (not simultanously, of course!) over the years.
Currently, my thinking is that _if_ setting it to NULL prevents a double
deletion, _then_ setting it to NULL most probably prevents detection of
a serious bug.
However, there can be other more valid reasons for setting a pointer to
NULL after deletion, e.g. for optimization purposes. For example,
deletions are rare, and this pointer is in the middle of an array of
pointers; MyData above would then be a reference to that array element.
Given the OP's definition of MyData I don't think that's the case here.
In short, I disagree.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?