> On 2009-07-13 10:55:33, Aleix Pol wrote:
> > it is not necessary to check if the object is null before deleting. code 
> > like:
> > 
> > if(a) delete a;
> > 
> > should be just "delete a;"
> > 
> > In C++ the null is 0, I think it's better to assign 0 than NULL.

This is not the problem, the problem is:

delete a; // in one class method

// In another class method:
if (a) // the result will the true even though a is deleted
        do a->"something" // this can crash the application

        I am more used to C than C++, I can change it to 0 if you wish. There 
are a 
lot of places in Kopete's source code that also uses NULL, and other places 
that use 0 and other places that uses 0L. Which one is the best to use (0 or 
0L)?


- Lamarque


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard.kde.org/r/1004/#review1568
-----------------------------------------------------------


On 2009-07-13 13:08:03, Lamarque Souza wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviewboard.kde.org/r/1004/
> -----------------------------------------------------------
> 
> (Updated 2009-07-13 13:08:03)
> 
> 
> Review request for Kopete.
> 
> 
> Summary
> -------
> 
> Reinitialise deleted pointers to NULL. Throughout all Kopete source code (not 
> only WLM protocol) pointers are deleted and not reinitialized, grep -r 
> 'delete '  $(find \( -name "*.cpp" -o -name "*.h" \) ) | wc returns 1105 
> lines, I can do a rough estimation of at least half of those lines do not 
> reinitialize pointers. Althouth reinitialing pointers are not always 
> necessary in some cases it does is necessary and by what I have seen there 
> are such places in Kopete's source code. Since analising 1105 linhes of code 
> is a really tiring and boring task I did it only for the WLM protocol for 
> now. Kopete::CommandHandler::slotExecFinished even passed one deleted pointer 
> to a function, which seems really wrong to me, it should delete the pointer 
> after calling the function, not before. To illustrate the problem assume a is 
> a class member pointer:
> 
> delete a; // in one class method
> 
> // In another class method:
> if (a) // the result will the true even though a is deleted
>         do a->"something" // this can crash the application
> 
> 
> Diffs
> -----
> 
>   /trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmchatmanager.cpp 993925 
>   /trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmlibmsn.cpp 993925 
>   /trunk/KDE/kdenetwork/kopete/protocols/wlm/wlmsocket.cpp 993925 
> 
> Diff: http://reviewboard.kde.org/r/1004/diff
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Lamarque
> 
>

_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel

Reply via email to