Skip to content

Commit

Permalink
Revert "SharedPtr: More cleanup"
Browse files Browse the repository at this point in the history
This reverts commit 392ffe1.
  • Loading branch information
glebm authored and xzyfer committed Nov 20, 2018
1 parent 430315a commit fdff442
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/memory/SharedPtr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ namespace Sass {
// AST_Node_Ptr ast = dynamic_cast<AST_Node*>(node);
if (node->dbg) std::cerr << "DELETE NODE " << node << "\n";
#endif
delete node;
node = NULL;
delete(node);
}
}
}
Expand Down
22 changes: 16 additions & 6 deletions src/memory/SharedPtr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -83,6 +80,9 @@ namespace Sass {
virtual const std::string to_string() const = 0;

virtual ~SharedObj();
long getRefCount() const {
return refcounter;
}
};


Expand Down Expand Up @@ -115,6 +115,9 @@ namespace Sass {
SharedObj* operator-> () const {
return node;
};
bool isNull () {
return node == NULL;
};
bool isNull () const {
return node == NULL;
};
Expand Down Expand Up @@ -176,8 +179,6 @@ namespace Sass {

~SharedImpl() {};
public:
using SharedPtr::isNull;
using SharedPtr::operator bool;
operator T*() const {
return static_cast<T*>(this->obj());
}
Expand All @@ -196,6 +197,15 @@ namespace Sass {
T* detach() {
return static_cast<T*>(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;
};
};

}
Expand Down

0 comments on commit fdff442

Please sign in to comment.