[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KDE 1.1.2 khtmlw memory leak patch - please test!
From:       Waldo Bastian <bastian () suse ! de>
Date:       1999-08-30 16:18:46
[Download RAW message or body]

On Mon, 30 Aug 1999, Stephan Kulow wrote:
> Bernd Gehrmann wrote:
> > 
> > On Mon, 30 Aug 1999 Waldo Bastian wrote:
> > 
> > >It's good programming practice to _always_ reset a pointer to 0 after
> > >delting it. Perhaps another destructor gets called (itn the parent
> > >object) which calls a virtual function which checks the pixmap
> > >pointer.....
> > 
> > >It's good programming practice to _always_ reset a pointer to 0 after
> > >delting it. Perhaps another destructor gets called (itn the parent
> > >object) which calls a virtual function which checks the pixmap
> > >pointer.....
> > 
> > These are exactly the considerations which led to the design decision
> > that in C++ this is not possible! After the execution of the destructor,
> > all variables declared in the corresponding class are undefined. So
> > setting a variable at the end of the destructor is not good programming
> > practice, as it deludes the reader of the code into thinking that the
> > assignment has any effect.
> This is not true. As Waldo pointed out, the variable may be owned by
> a base class, so setting it to 0 has an effect.

No... I was indeed referring to the case where the variable is owned by
the destructed class. So Bernd is right. Non the less I still
think that it is good practive to always reset a pointer to 0 even if
isn't needed at a particular point. 

Cheers,
Waldo

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic