← Back to team overview

kicad-developers team mailing list archive

Re: Bug fixing and Coverity scan errors.

 

On 3/31/2015 8:49 AM, Mário Luzeiro wrote:
>> I think it would be good policy to say unless the scope of the pointer
>> variable is the local code block, delete must be immediately followed
>> by a NULL assignment. i.e. from what I'm looking at now in the
>> vrml_v2_modelparser.cpp:241 or :263
> 
>>    delete m_model;
> 
>> should really be:
> 
>>    delete m_model;
>>    m_model = NULL;
> 
> That should be desirable to set it to NULL.
> I am not a C++ expert but, are we missing a "safe delete" thing to use in KiCad?

What do you mean by "safe" delete?  It's always the responsibility of
the programmer to know when it's safe to delete an object created on the
heap.  C++ cannot know when it's safe to delete an object.  If you mean
automatic heap deletion, you can use the C++ auto_ptr or Boost smart_ptr
templates.  Using them requires some understanding.  Otherwise, they can
be just as unsafe as delete.

> 
> Mario Luzeiro
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
> 


Follow ups

References