[Libreoffice] [PUSHED, partial] Remove NULL checks from delete
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Fri Nov 18 03:51:10 PST 2011
On Fri, Nov 18, 2011 at 12:30:41PM +0100, Stephan Bergmann wrote:
> On 11/10/2011 12:05 AM, Andrew Douglas Pitonyak wrote:
> >I would feel safer if pointers were set to NULL (or nullptr if we
> >support C++11) since it is not safe to delete a pointer twice.
>
> I would rather argue that adding redundant "p = 0;" following a
> "delete p;" makes our code worse, not better (even if that may sound
> paradoxical at first):
> [...]
I generally agree, but for debugging (non-product builds only) it might make
sense to mark a pointer as dead, to easier identify if the zombie pointer is
still dereferenced. But that should not be a NULL even in that case (which
might trigger overly defensive workarounds), rather something like 0xDEADBEEF.
Mind you: I am not talking about release builds.
Best,
Bjoern
More information about the LibreOffice
mailing list