[Digikam-devel] Re: delete does not reset the pointer in GCC (4.6.0)

Gilles Caulier caulier.gilles at gmail.com
Wed Jun 15 13:17:37 BST 2011


2011/6/15 Andi Clemens <andi.clemens at gmx.net>

> Right, we are still using too many raw pointers.
> Qt, C++ stdlib and boost have many things to handle pointers automatically.
>

Yes. this one is exactly that we need :

http://doc.qt.nokia.com/4.7/qpointer.html


> See Item #13 in "Effective C++": Use objects to manage resources
> A great book, everyone should read it...
>
>
Do you have an url ?


> Anyway sure auto_ptr and friends will "slow" down execution, but with all
> the checks we do anyway, I guess it will not be noticeable.
> It is still much faster than garbage collection...
>
>
Perhaps we will need to patch code about to use QPointer everywhere when
it's necessary...

Gilles


> Andi
>
>
> On Wed, 15 Jun 2011 11:55:50 +0200, Marcel Wiesweg <marcel.wiesweg at gmx.de>
> wrote:
>
> >
> >> a few months ago, maybe 2 years.
> >> I know that I always added
> >> xyz = 0;
> >> to my code before, but then it was removed again because it is not
> >> neccessary with modern compilers (I don't know who said that).
> >
> > When googling and reading through the usual sources (stackoverflow etc.)
> > I see noone saying that any compiler sets a pointer to 0, I would even
> > guess delete should _not_ change the value of the passed pointer unless
> > the C++ standard says so.
> > There are the usual stories not to use raw pointers and use concepts to
> > make sure you are always sure never to use deleted pointers again, but
> > in the end, if you are playing with raw pointers (which we are doing
> > still in too many areas IMO, but getting less) and need to delete and
> > reuse the variable, be sure to set it to 0.
> >
> > Marcel
>
>
> --
> Using Opera's revolutionary email client: http://www.opera.com/mail/
> _______________________________________________
> Digikam-devel mailing list
> Digikam-devel at kde.org
> https://mail.kde.org/mailman/listinfo/digikam-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/digikam-devel/attachments/20110615/9adf3bf6/attachment.html>


More information about the Digikam-devel mailing list