summaryrefslogtreecommitdiff
path: root/src/misc/countedptr.hpp
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-04-10 22:07:06 +0100
committerMichael Lutz <michi@icosahedron.de>2019-04-10 23:22:20 +0200
commit7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch)
tree99f134b7e66367cf11e10bc5061896eab4a3264f /src/misc/countedptr.hpp
parent3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff)
downloadopenttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/misc/countedptr.hpp')
-rw-r--r--src/misc/countedptr.hpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/misc/countedptr.hpp b/src/misc/countedptr.hpp
index e7b28a626..83d0e036d 100644
--- a/src/misc/countedptr.hpp
+++ b/src/misc/countedptr.hpp
@@ -34,8 +34,8 @@ protected:
Tcls *m_pT;
public:
- /** default (NULL) construct or construct from a raw pointer */
- inline CCountedPtr(Tcls *pObj = NULL) : m_pT(pObj)
+ /** default (nullptr) construct or construct from a raw pointer */
+ inline CCountedPtr(Tcls *pObj = nullptr) : m_pT(pObj)
{
AddRef();
}
@@ -56,16 +56,16 @@ protected:
/** add one ref to the underlaying object */
inline void AddRef()
{
- if (m_pT != NULL) m_pT->AddRef();
+ if (m_pT != nullptr) m_pT->AddRef();
}
public:
/** release smart pointer (and decrement ref count) if not null */
inline void Release()
{
- if (m_pT != NULL) {
+ if (m_pT != nullptr) {
Tcls *pT = m_pT;
- m_pT = NULL;
+ m_pT = nullptr;
pT->Release();
}
}
@@ -73,21 +73,21 @@ public:
/** dereference of smart pointer - const way */
inline const Tcls *operator->() const
{
- assert(m_pT != NULL);
+ assert(m_pT != nullptr);
return m_pT;
}
/** dereference of smart pointer - non const way */
inline Tcls *operator->()
{
- assert(m_pT != NULL);
+ assert(m_pT != nullptr);
return m_pT;
}
/** raw pointer casting operator - const way */
inline operator const Tcls*() const
{
- assert(m_pT == NULL);
+ assert(m_pT == nullptr);
return m_pT;
}
@@ -100,7 +100,7 @@ public:
/** operator & to support output arguments */
inline Tcls** operator&()
{
- assert(m_pT == NULL);
+ assert(m_pT == nullptr);
return &m_pT;
}
@@ -121,16 +121,16 @@ public:
/** assignment operator helper */
inline void Assign(Tcls *pT);
- /** one way how to test for NULL value */
+ /** one way how to test for nullptr value */
inline bool IsNull() const
{
- return m_pT == NULL;
+ return m_pT == nullptr;
}
- /** another way how to test for NULL value */
+ /** another way how to test for nullptr value */
//inline bool operator == (const CCountedPtr &sp) const {return m_pT == sp.m_pT;}
- /** yet another way how to test for NULL value */
+ /** yet another way how to test for nullptr value */
//inline bool operator != (const CCountedPtr &sp) const {return m_pT != sp.m_pT;}
/** assign pointer w/o incrementing ref count */
@@ -144,7 +144,7 @@ public:
inline Tcls *Detach()
{
Tcls *pT = m_pT;
- m_pT = NULL;
+ m_pT = nullptr;
return pT;
}
};
@@ -154,10 +154,10 @@ inline void CCountedPtr<Tcls_>::Assign(Tcls *pT)
{
/* if they are the same, we do nothing */
if (pT != m_pT) {
- if (pT != NULL) pT->AddRef(); // AddRef new pointer if any
+ if (pT != nullptr) 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 != NULL) pTold->Release(); // release old ptr if any
+ if (pTold != nullptr) pTold->Release(); // release old ptr if any
}
}