diff options
-rw-r--r-- | src/piraha/smart_ptr.hpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/piraha/smart_ptr.hpp b/src/piraha/smart_ptr.hpp index 1d9dcf6f..71e3b4d6 100644 --- a/src/piraha/smart_ptr.hpp +++ b/src/piraha/smart_ptr.hpp @@ -135,6 +135,8 @@ class smart_ptr { } void operator=(const smart_ptr<T>& s) { assert(this != NULL); + if(guts == s.guts) + return; clean(); guts = s.guts; if(guts != NULL) @@ -162,7 +164,7 @@ class smart_ptr { bool valid() const { return guts != NULL && guts->ptr != NULL; } - int ref_count() { + int ref_count() const { assert(guts != NULL); return guts->ref_count_(); } |