diff options
author | Henry Wilson <m3henry@googlemail.com> | 2019-04-10 22:07:06 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2019-04-10 23:22:20 +0200 |
commit | 7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch) | |
tree | 99f134b7e66367cf11e10bc5061896eab4a3264f /src/core/pool_type.hpp | |
parent | 3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff) | |
download | openttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz |
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/core/pool_type.hpp')
-rw-r--r-- | src/core/pool_type.hpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp index 38f314ebb..61dd29213 100644 --- a/src/core/pool_type.hpp +++ b/src/core/pool_type.hpp @@ -91,7 +91,7 @@ struct Pool : PoolBase { size_t size; ///< Current allocated size size_t first_free; ///< No item with index lower than this is free (doesn't say anything about this one!) size_t first_unused; ///< This and all higher indexes are free (doesn't say anything about first_unused-1 !) - size_t items; ///< Number of used indexes (non-NULL) + size_t items; ///< Number of used indexes (non-nullptr) #ifdef OTTD_ASSERT size_t checked; ///< Number of items we checked for #endif /* OTTD_ASSERT */ @@ -115,13 +115,13 @@ struct Pool : PoolBase { } /** - * Tests whether given index can be used to get valid (non-NULL) Titem + * Tests whether given index can be used to get valid (non-nullptr) Titem * @param index index to examine - * @return true if PoolItem::Get(index) will return non-NULL pointer + * @return true if PoolItem::Get(index) will return non-nullptr pointer */ inline bool IsValidID(size_t index) { - return index < this->first_unused && this->Get(index) != NULL; + return index < this->first_unused && this->Get(index) != nullptr; } /** @@ -150,7 +150,7 @@ struct Pool : PoolBase { * Allocates space for new Titem * @param size size of Titem * @return pointer to allocated memory - * @note can never fail (return NULL), use CanAllocate() to check first! + * @note can never fail (return nullptr), use CanAllocate() to check first! */ inline void *operator new(size_t size) { @@ -164,7 +164,7 @@ struct Pool : PoolBase { */ inline void operator delete(void *p) { - if (p == NULL) return; + if (p == nullptr) return; Titem *pn = (Titem *)p; assert(pn == Tpool->Get(pn->index)); Tpool->FreeItem(pn->index); @@ -175,7 +175,7 @@ struct Pool : PoolBase { * @param size size of Titem * @param index index of item * @return pointer to allocated memory - * @note can never fail (return NULL), use CanAllocate() to check first! + * @note can never fail (return nullptr), use CanAllocate() to check first! * @pre index has to be unused! Else it will crash */ inline void *operator new(size_t size, size_t index) @@ -228,9 +228,9 @@ struct Pool : PoolBase { } /** - * Tests whether given index can be used to get valid (non-NULL) Titem + * Tests whether given index can be used to get valid (non-nullptr) Titem * @param index index to examine - * @return true if PoolItem::Get(index) will return non-NULL pointer + * @return true if PoolItem::Get(index) will return non-nullptr pointer */ static inline bool IsValidID(size_t index) { @@ -252,11 +252,11 @@ struct Pool : PoolBase { * Returns Titem with given index * @param index of item to get * @return pointer to Titem - * @note returns NULL for invalid index + * @note returns nullptr for invalid index */ static inline Titem *GetIfValid(size_t index) { - return index < Tpool->first_unused ? Tpool->Get(index) : NULL; + return index < Tpool->first_unused ? Tpool->Get(index) : nullptr; } /** @@ -282,7 +282,7 @@ struct Pool : PoolBase { * Dummy function called after destructor of each member. * If you want to use it, override it in PoolItem's subclass. * @param index index of deleted item - * @note when this function is called, PoolItem::Get(index) == NULL. + * @note when this function is called, PoolItem::Get(index) == nullptr. * @note it's called only when !CleaningPool() */ static inline void PostDestructor(size_t index) { } @@ -314,8 +314,8 @@ private: }; #define FOR_ALL_ITEMS_FROM(type, iter, var, start) \ - for (size_t iter = start; var = NULL, iter < type::GetPoolSize(); iter++) \ - if ((var = type::Get(iter)) != NULL) + for (size_t iter = start; var = nullptr, iter < type::GetPoolSize(); iter++) \ + if ((var = type::Get(iter)) != nullptr) #define FOR_ALL_ITEMS(type, iter, var) FOR_ALL_ITEMS_FROM(type, iter, var, 0) |