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

2011-11-18 Thread Stephan Bergmann
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

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

2011-11-18 Thread Michael Meeks
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

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

2011-11-17 Thread Michael Meeks
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

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

2011-11-17 Thread Ivan Timofeev
I have played with manual solving of this problem today... :-) There are the more interesting examples: - else if(pUserMarker) + else { delete pUserMarker; pUserMarker = 0L; } and - if( GetPageNum() 0 pCntntAnchor ) + if( GetPageNum() 0 ) { delete pCntntAnchor; Actually,

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

2011-11-16 Thread Andrew Douglas Pitonyak
On 11/10/2011 05:14 AM, Caolán McNamara wrote: On Wed, 2011-11-09 at 18:05 -0500, Andrew Douglas Pitonyak wrote: 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.

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

2011-11-16 Thread Kohei Yoshida
On Wed, 2011-11-16 at 21:05 -0500, Andrew Douglas Pitonyak wrote: 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. Safe if the variable that holds the pointer is likely to be accessed again. If not, it's

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

2011-11-10 Thread Caolán McNamara
On Wed, 2011-11-09 at 18:05 -0500, Andrew Douglas Pitonyak wrote: 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. ?, convert all delete to e.g. DELETEZ, i.e.

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

2011-11-07 Thread Caolán McNamara
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