New shared pointer - revision 2

Frerich Raabe raabe at kde.org
Sat Sep 10 06:50:10 BST 2005


On Saturday 10 September 2005 02:53, Thiago Macieira wrote:
> The code path is this:

[..]
> Suppose d->ref == 2.

[..]

Yes, you are right of course, I don't know what I was thinking. Maybe it's 
true that I should not do such things in the middle of the night. The copy 
constructor should simply be

template <class T>
KSharedPtr<T>::KSharedPtr( const KSharedPtr<T> &other )
{
	KSharedData *x = other.d;
	x = qAtomicSetPtr( &d, x );
	d->ref.ref();
}

and the assignment operator from T* should be like you outlined in one of the 
other mails.

- Frerich
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050910/1f1cfef4/attachment.sig>


More information about the kde-core-devel mailing list