[Insight-developers] CPPCheck Suggested Changes?

kent williams norman-k-williams at uiowa.edu
Thu Sep 3 17:13:47 EDT 2009


The good news is that CPPCheck doesn't find any outright coding errors,
which it's actually pretty good at detecting.  That doesn't mean there
aren't any, just that if they're are, they're too convoluted and tricky for
CPPCheck  to detect.

It did find some possible memory leaks, but they are in cases where memory
doesn't get freed because itkExceptionMacro is called and an exception gets
thrown.

I have a question about one of the most common suggestions:  Since delete 0
and delete [] 0 are legal and harmless, it recommends not checking for 0
before deleting.  This happens so frequently in the ITK library, it looks as
though it was done on purpose.  Should I take those out, e.g.

if(this->m_Something)
{
    delete this->m_Something;
}

becomes simply

delete this->m_Something;




More information about the Insight-developers mailing list