diff options
author | rubidium <rubidium@openttd.org> | 2009-01-10 00:31:47 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-01-10 00:31:47 +0000 |
commit | 28ea38ae5572d99598aa400fb62eb38f5f7ffd7b (patch) | |
tree | 29e703244d28f29c8634b2d30f42b34852fe74bc /src/misc/countedptr.hpp | |
parent | 86d50b6415635d1f1fb87bd62f1e08aa7b8f0033 (diff) | |
download | openttd-28ea38ae5572d99598aa400fb62eb38f5f7ffd7b.tar.xz |
(svn r14949) -Cleanup: pointer coding style
Diffstat (limited to 'src/misc/countedptr.hpp')
-rw-r--r-- | src/misc/countedptr.hpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/misc/countedptr.hpp b/src/misc/countedptr.hpp index c19e64b0b..59e1273a6 100644 --- a/src/misc/countedptr.hpp +++ b/src/misc/countedptr.hpp @@ -23,11 +23,11 @@ public: protected: /** here we hold our pointer to the target */ - Tcls* m_pT; + Tcls *m_pT; public: /** default (NULL) construct or construct from a raw pointer */ - FORCEINLINE CCountedPtr(Tcls* pObj = NULL) : m_pT(pObj) {AddRef();}; + FORCEINLINE CCountedPtr(Tcls *pObj = NULL) : m_pT(pObj) {AddRef();}; /** copy constructor (invoked also when initializing from another smart ptr) */ FORCEINLINE CCountedPtr(const CCountedPtr& src) : m_pT(src.m_pT) {AddRef();}; @@ -41,13 +41,13 @@ protected: public: /** 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();}} + FORCEINLINE void Release() {if (m_pT != NULL) {Tcls *pT = m_pT; m_pT = NULL; pT->Release();}} /** dereference of smart pointer - const way */ - FORCEINLINE const Tcls* operator -> () const {assert(m_pT != NULL); return m_pT;}; + FORCEINLINE const Tcls *operator -> () const {assert(m_pT != NULL); return m_pT;}; /** dereference of smart pointer - non const way */ - FORCEINLINE Tcls* operator -> () {assert(m_pT != NULL); return m_pT;}; + FORCEINLINE Tcls *operator -> () {assert(m_pT != NULL); return m_pT;}; /** raw pointer casting operator - const way */ FORCEINLINE operator const Tcls*() const {assert(m_pT == NULL); return m_pT;} @@ -59,13 +59,13 @@ public: FORCEINLINE Tcls** operator &() {assert(m_pT == NULL); return &m_pT;} /** assignment operator from raw ptr */ - FORCEINLINE CCountedPtr& operator = (Tcls* pT) {Assign(pT); return *this;} + FORCEINLINE CCountedPtr& operator = (Tcls *pT) {Assign(pT); return *this;} /** assignment operator from another smart ptr */ FORCEINLINE CCountedPtr& operator = (const CCountedPtr& src) {Assign(src.m_pT); return *this;} /** assignment operator helper */ - FORCEINLINE void Assign(Tcls* pT); + FORCEINLINE void Assign(Tcls *pT); /** one way how to test for NULL value */ FORCEINLINE bool IsNull() const {return m_pT == NULL;} @@ -77,19 +77,19 @@ public: //FORCEINLINE bool operator != (const CCountedPtr& sp) const {return m_pT != sp.m_pT;} /** assign pointer w/o incrementing ref count */ - FORCEINLINE void Attach(Tcls* pT) {Release(); m_pT = pT;} + FORCEINLINE void Attach(Tcls *pT) {Release(); m_pT = pT;} /** detach pointer w/o decrementing ref count */ - FORCEINLINE Tcls* Detach() {Tcls* pT = m_pT; m_pT = NULL; return pT;} + FORCEINLINE Tcls *Detach() {Tcls *pT = m_pT; m_pT = NULL; return pT;} }; template <class Tcls_> -FORCEINLINE void CCountedPtr<Tcls_>::Assign(Tcls* pT) +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 + 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 } |