[PATCH] kdelibs: Memory leaks (d-pointer not deleted) fixed
Thiago Macieira
thiago.macieira at kdemail.net
Thu Oct 28 19:58:00 BST 2004
Andrew Coles wrote:
>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.
That's correct. The implementation is more efficient, since the d pointer
cannot change during the existence of the class.
However, that doesn't change the fact that it leaks or that the fix won't be
seen by old code.
--
Thiago Macieira - Registered Linux user #65028
thiago (AT) macieira (DOT) info
ICQ UIN: 1967141 PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20041028/81047003/attachment.sig>
More information about the kde-core-devel
mailing list