C++ delete (Re: [sword-devel] Notes on the search progress bug)

Joachim Ansorg sword-devel@crosswire.org
Sun, 29 Oct 2000 14:43:21 +0000


Am Sonntag, 29. Oktober 2000 03:45 schrieben Sie:
> "Troy A. Griffitts" wrote:
> > ...
> >      if (scope)
> >           delete scope;
> > ...
>
> Why is there so much code like this in Sword?  Doesn't the C++ standard
> guarantee that delete will behave appropriately on a null pointer?  If
> so, this code is redundant and confusing - it makes it look like scope
> is a boolean.  (All of this is one more good reason to use Java.  :-)

It's only treated as a bool if we do "scope = 0" before (e.g. in the 
constructor of CSwordModuleInfo). if() does only check if it's ==0 (false) or 
!=0 (true).

C++ is faster than Java :)
--Joachim