X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Frefptr.h;h=79401dce5be40094a9f55212c0c3fb4abd8f7dc9;hp=34560ec0389beea43bbfb66fe2db1bd111bb954a;hb=HEAD;hpb=41363aed34382386f915f17c1a961750b4fdcb14 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);