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


On 11/07/2011 07:50 AM, Caolán McNamara wrote:
On Mon, 2011-09-19 at 20:58 +0200, Thomas Arnhold wrote:
Hi,

I've recently seen some changes, which removed unnecessary NULL checks
for delete commands with the form:

-    if (pTextPContext)
-        delete pTextPContext;
+    delete pTextPContext;

Codebase is full with these. I've attached a little perl script which
should solve this conversion. I've attached a sample for the vcl dir.

Any objections?
Those extraneous if's annoy me alright, but a mass conversion would need
more cunning, e.g. extra stuff done inside the if, and else branches,
e.g. the sample patch has this catch...

-    if ( mpDisplayDev )
-        delete mpDisplayDev;
+    delete mpDisplayDev;
      else
      {

so end up with a bare else. I pushed the working bits in the mean time.


I assume that this would check for an array as well.

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.

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info:  http://www.pitonyak.org/oo.php


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.