From fdff44261bc9e00b12455138afdf6a8b07f9bbb9 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Mon, 19 Nov 2018 22:57:17 +0000 Subject: [PATCH] Revert "SharedPtr: More cleanup" This reverts commit 392ffe19ecc0d1adcce9b09820c37d87dc3cf9bd. --- src/memory/SharedPtr.cpp | 3 +-- src/memory/SharedPtr.hpp | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/memory/SharedPtr.cpp b/src/memory/SharedPtr.cpp index c56b75e3e..b4f5ef48b 100644 --- a/src/memory/SharedPtr.cpp +++ b/src/memory/SharedPtr.cpp @@ -62,8 +62,7 @@ namespace Sass { // AST_Node_Ptr ast = dynamic_cast(node); if (node->dbg) std::cerr << "DELETE NODE " << node << "\n"; #endif - delete node; - node = NULL; + delete(node); } } } diff --git a/src/memory/SharedPtr.hpp b/src/memory/SharedPtr.hpp index 4c145b66c..fbfd00312 100644 --- a/src/memory/SharedPtr.hpp +++ b/src/memory/SharedPtr.hpp @@ -48,7 +48,7 @@ namespace Sass { size_t line; #endif static bool taint; - size_t refcounter; + long refcounter; #ifdef DEBUG_SHARED_PTR bool dbg; #endif @@ -72,9 +72,6 @@ namespace Sass { void setDbg(bool dbg) { this->dbg = dbg; } - size_t getRefCount() const { - return refcounter; - } #endif static void setTaint(bool val) { taint = val; @@ -83,6 +80,9 @@ namespace Sass { virtual const std::string to_string() const = 0; virtual ~SharedObj(); + long getRefCount() const { + return refcounter; + } }; @@ -115,6 +115,9 @@ namespace Sass { SharedObj* operator-> () const { return node; }; + bool isNull () { + return node == NULL; + }; bool isNull () const { return node == NULL; }; @@ -176,8 +179,6 @@ namespace Sass { ~SharedImpl() {}; public: - using SharedPtr::isNull; - using SharedPtr::operator bool; operator T*() const { return static_cast(this->obj()); } @@ -196,6 +197,15 @@ namespace Sass { T* detach() { return static_cast(SharedPtr::detach()); } + bool isNull() const { + return this->obj() == NULL; + } + bool operator<(const T& rhs) const { + return *this->ptr() < rhs; + }; + operator bool() const { + return this->obj() != NULL; + }; }; }