Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index



On Wed, 2011-11-16 at 21:05 -0500, 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.
?, convert all delete to e.g. DELETEZ, i.e. delete foo, foo = NULL ?
Wouldn't be a fan of that, c++ is the language that it is, need to live
with that and not try and make it something that it isn't.

Setting a pointer to NULL after deleting the contents of the pointer is 
safe so that if you go to delete it again it is not a problem.

        Sure, it would be somewhat safer for some minority of cases. However
the DELETEZ macro looks hyper-ugly in the code and makes it less
readable. Hopefully we mostly delete things in destructors - where
DELETEZ is a waste of time - we can have our (sadly) custom allocator
wipe or invalidate the memory post delete in a single line of code if we
want to (actually we should prolly do that as an easy-hack if it is not
there already ;-).

        If we have a bug whereby something is deleted in-the code without being
re-assigned, and where NULL is a valid value, then we could fix those
with a DELETEZ construct, but - finding those places (that don't already
have a subsequent assignment) is prolly more exciting :-) In theory some
code analysis framework could help find those guys.

        Does that give more detail ?

        Anyhow, thanks for your nice code cleanup ! it's nice to see.

        All the best,

                Michael.

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


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.