[Insight-users] UnRegister question

dean.inglis@on.aibn.com dean.inglis@on.aibn.com
Mon, 17 Feb 2003 11:55:59 -0500


In itkSmartPointer.h, why is it that
the UnRegister function does not check the
reference count on the object it points to
and then explicitly set m_pointer to NULL (0) 
if required?
  
void UnRegister()
    {
***->    if(m_Pointer) { m_Pointer->UnRegister(); }
    }

i.e, why is the following not done?:

void UnRegister()
    {
    if(m_Pointer) 
      {               
       int count = m_Pointer->GetReferenceCount();
       m_Pointer->UnRegister();          
       if(count == 1){ m_Pointer = 0; }        
       }
    }


Dean