[PATCH] kdelibs: Memory leaks (d-pointer not deleted) fixed
Andrew Coles
andrew_coles at yahoo.co.uk
Thu Oct 28 12:57:57 BST 2004
On Thursday 28 Oct 2004 12:18, Thiago Macieira wrote:
>There's also the case of KCharSelect, in which the destructor is now added,
> instead of the implicit one. That doesn't break binary compatibility, but
> old code will not see the improvement.
Just looking at KCharSelect, is there a good reason why it isn't:
KCharSelectPrivate* const d;
instead of
KCharSelectPrivate *d;
and then initialise d using the initialisation syntax instead of as the first
line of the constructor, i.e.
... QVBox( parent, name ), d(new KCharSelectPrivate) {
instead of
... QVBox( parent, name ) {
d = new KCharSelectPrivate;
If my understanding of const-based optimisations is correct, this would be
more efficient as the class methods could assume that the pointer d hasn't
changed between references to it.
Oh, and I personally prefer using auto_ptr for pointer data members [1] - it
gets around the whole issue of being able to miss the delete.
Andrew
[1] http://www.gotw.ca/publications/using_auto_ptr_effectively.htm
More information about the kde-core-devel
mailing list