diff --git a/src/core/pool_func.hpp b/src/core/pool_func.hpp index bea4f45b2c..0012b682d8 100644 --- a/src/core/pool_func.hpp +++ b/src/core/pool_func.hpp @@ -115,17 +115,17 @@ DEFINE_POOL_METHOD(inline void *)::AllocateItem(size_t size, size_t index) Titem *item; if (Tcache && this->alloc_cache != nullptr) { assert(sizeof(Titem) == size); - item = (Titem *)this->alloc_cache; + item = reinterpret_cast(this->alloc_cache); this->alloc_cache = this->alloc_cache->next; if (Tzero) { /* Explicitly casting to (void *) prevents a clang warning - * we are actually memsetting a (not-yet-constructed) object */ - memset((void *)item, 0, sizeof(Titem)); + memset(static_cast(item), 0, sizeof(Titem)); } } else if (Tzero) { - item = (Titem *)CallocT(size); + item = reinterpret_cast(CallocT(size)); } else { - item = (Titem *)MallocT(size); + item = reinterpret_cast(MallocT(size)); } this->data[index] = item; SetBit(this->used_bitmap[index / BITMAP_SIZE], index % BITMAP_SIZE); @@ -188,7 +188,7 @@ DEFINE_POOL_METHOD(void)::FreeItem(size_t index) assert(index < this->size); assert(this->data[index] != nullptr); if (Tcache) { - AllocCache *ac = (AllocCache *)this->data[index]; + AllocCache *ac = reinterpret_cast(this->data[index]); ac->next = this->alloc_cache; this->alloc_cache = ac; } else { diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp index bb4cc4f96f..fb0e822ac3 100644 --- a/src/core/pool_type.hpp +++ b/src/core/pool_type.hpp @@ -78,8 +78,8 @@ private: */ template struct Pool : PoolBase { - /* Ensure Tmax_size is within the bounds of Tindex. */ - static_assert((uint64_t)(Tmax_size - 1) >> 8 * sizeof(Tindex) == 0); + /* Ensure the highest possible index, i.e. Tmax_size -1, is within the bounds of Tindex. */ + static_assert(Tmax_size - 1 <= MAX_UVALUE(Tindex)); static constexpr size_t MAX_SIZE = Tmax_size; ///< Make template parameter accessible from outside @@ -259,7 +259,7 @@ struct Pool : PoolBase { inline void operator delete(void *p) { if (p == nullptr) return; - Titem *pn = (Titem *)p; + Titem *pn = static_cast(p); assert(pn == Tpool->Get(pn->index)); Tpool->FreeItem(pn->index); }