[Libreoffice] [PUSHED, partial] Remove NULL checks from delete

Michael Meeks michael.meeks at suse.com
Fri Nov 18 07:38:23 PST 2011


On Fri, 2011-11-18 at 12:51 +0100, Bjoern Michaelsen wrote:
> > 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.

	Ditto, the code should (ideally) be clean, sweet, easy to read, free
from redundancy (of which this is a kind), have unit tests etc. :-) at
least, I hope that's the goal.

>  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.

	IMHO it would make some sense to zero memory at both allocate and free
time in product builds; it is a linear incremental cost of course - but
(perhaps) frees us from some of these uninitialized corner-case bugs
that we see around the place [ though I forget if we're using the sal/
allocator for general 'new' calls - presuambly so ].

	Of course, it'd be the first thing to show up on a profile, but ...
that's only meaningful for the micro-optimisers who don't see the big
picture ;->

	IIRC the export MALLOC_CHECK_=2 we see in ooenv already sets memory
dirting on free for our development builds anyway, and we seem to do
quite well there.

	HTH,

		Michael.

-- 
michael.meeks at suse.com  <><, Pseudo Engineer, itinerant idiot



More information about the LibreOffice mailing list