Changeset 7d0881c
- Timestamp:
- Jun 28, 2019, 11:59:00 AM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 55b6476
- Parents:
- e0e9a0b
- Location:
- src/AST
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Node.cpp
re0e9a0b r7d0881c 50 50 51 51 template< typename node_t, enum ast::Node::ref_type ref_t > 52 void ast::ptr_base<node_t, ref_t>::_dec( const node_t * node ) {52 void ast::ptr_base<node_t, ref_t>::_dec( const node_t * node, bool do_delete ) { 53 53 _trap( node ); 54 node->decrement(ref_t );54 node->decrement(ref_t, do_delete ); 55 55 } 56 56 -
src/AST/Node.hpp
re0e9a0b r7d0881c 69 69 } 70 70 71 void decrement(ast::Node::ref_type ref ) const {71 void decrement(ast::Node::ref_type ref, bool do_delete = true) const { 72 72 switch (ref) { 73 73 case ref_type::strong: strong_count--; break; … … 75 75 } 76 76 77 if( !strong_count && !weak_count) {77 if( do_delete && !strong_count && !weak_count) { 78 78 delete this; 79 79 } … … 228 228 operator const node_t * () const { _check(); return node; } 229 229 230 const node_t * release() { 231 const node_t * ret = node; 232 if ( node ) { 233 _dec(node, false); 234 node = nullptr; 235 } 236 return ret; 237 } 238 230 239 /// wrapper for convenient access to dynamic_cast 231 240 template<typename o_node_t> … … 253 262 254 263 void _inc( const node_t * other ); 255 void _dec( const node_t * other );264 void _dec( const node_t * other, bool do_delete = true ); 256 265 void _check() const; 257 266
Note: See TracChangeset
for help on using the changeset viewer.