This repository was archived by the owner on Oct 24, 2025. It is now read-only.
  
  
  
  
    
    
    
      
    
  
  
    
File tree Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Original file line number Diff line number Diff line change @@ -32,12 +32,11 @@ namespace Sass {
3232  bool  SharedObj::taint = false ;
3333
3434  SharedObj::SharedObj ()
35-   : detached( false )
35+   : refcounter( 0 )
3636    #ifdef  DEBUG_SHARED_PTR
3737    , dbg(false )
3838    #endif 
3939  {
40-     refcounter = 0 ;
4140    #ifdef  DEBUG_SHARED_PTR
4241      if  (taint) all.push_back (this );
4342    #endif 
@@ -63,17 +62,14 @@ namespace Sass {
6362          //  AST_Node_Ptr ast = dynamic_cast<AST_Node*>(node);
6463          if  (node->dbg ) std::cerr << " DELETE NODE "   << node << " \n "  ;
6564        #endif 
66-         if  (!node->detached ) {
67-           delete (node);
68-         }
65+         delete (node);
6966      }
7067    }
7168  }
7269
7370  void  SharedPtr::incRefCount () {
7471    if  (node) {
7572      ++ node->refcounter ;
76-       node->detached  = false ;
7773      #ifdef  DEBUG_SHARED_PTR
7874        if  (node->dbg ) {
7975          std::cerr << " + "   << node << "  X "   << node->refcounter  << "  ("   << this  << " ) "   << " \n "  ;
@@ -111,4 +107,4 @@ namespace Sass {
111107    incRefCount ();
112108  }
113109
114- }
110+ }
Original file line number Diff line number Diff line change @@ -49,8 +49,6 @@ namespace Sass {
4949    #endif 
5050    static  bool  taint;
5151    long  refcounter;
52-     //  long refcount;
53-     bool  detached;
5452    #ifdef  DEBUG_SHARED_PTR
5553      bool  dbg;
5654    #endif 
@@ -82,7 +80,7 @@ namespace Sass {
8280    virtual  const  std::string to_string () const  = 0;
8381
8482    virtual  ~SharedObj ();
85-     long  getRefCount () {
83+     long  getRefCount () const   {
8684      return  refcounter;
8785    }
8886  };
@@ -123,11 +121,10 @@ namespace Sass {
123121    bool  isNull  () const  {
124122      return  node == NULL ;
125123    };
126-     SharedObj* detach () const  {
127-       if  (node) {
128-         node->detached  = true ;
129-       }
130-       return  node;
124+     SharedObj* detach () {
125+       SharedObj* result = node;
126+       node = NULL ;
127+       return  result;
131128    };
132129    operator  bool () const  {
133130      return  node != NULL ;
@@ -197,8 +194,7 @@ namespace Sass {
197194    T* ptr  () const  {
198195      return  static_cast <T*>(this ->obj ());
199196    };
200-     T* detach () const  {
201-       if  (this ->obj () == NULL ) return  NULL ;
197+     T* detach () {
202198      return  static_cast <T*>(SharedPtr::detach ());
203199    }
204200    bool  isNull () const  {
@@ -214,4 +210,4 @@ namespace Sass {
214210
215211}
216212
217- #endif 
213+ #endif 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments