X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Frefptr.h;h=1a164c1a90eafe69d3eab755b971400ff1f3e275;hb=af9f2e378f3adea7e636bac3c320ad2272af7612;hp=34560ec0389beea43bbfb66fe2db1bd111bb954a;hpb=41363aed34382386f915f17c1a961750b4fdcb14;p=libs%2Fcore.git diff --git a/source/core/refptr.h b/source/core/refptr.h index 34560ec..1a164c1 100644 --- a/source/core/refptr.h +++ b/source/core/refptr.h @@ -10,10 +10,8 @@ struct RefCounts KEEP = 1U<<(sizeof(unsigned)*8-1) }; - unsigned count; - unsigned weak_count; - - RefCounts(): count(0), weak_count(0) { } + unsigned count = 0; + unsigned weak_count = 0; }; template @@ -151,6 +149,9 @@ template template RefPtr &RefPtr::assign(const RefPtr &p) { + if(static_cast(&p)==this) + return *this; + decref(); data = p.data; counts = p.counts; @@ -195,6 +196,9 @@ template template WeakPtr &WeakPtr::assign(const WeakPtr &p) { + if(&p==this) + return *this; + decref(); data = p.get(); counts = (data ? p.counts : nullptr);