/** release smart pointer (and decrement ref count) if not null */ inline void Release() { if (m_pT != NULL) { Tcls *pT = m_pT; m_pT = NULL; pT->Release(); } }
FORCEINLINE void CCountedPtr<Tcls_>::Assign(Tcls *pT) { /* if they are the same, we do nothing */ if (pT != m_pT) { if (pT) pT->AddRef(); // AddRef new pointer if any Tcls *pTold = m_pT; // save original ptr m_pT = pT; // update m_pT to new value if (pTold) pTold->Release(); // release old ptr if any } }
/** release smart pointer (and decrement ref count) if not null */ FORCEINLINE void Release() {if (m_pT != NULL) {Tcls *pT = m_pT; m_pT = NULL; pT->Release();}}