diff --git a/src/cargopacket.h b/src/cargopacket.h index 477f9b07bc..10f9e78c8f 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -25,7 +25,7 @@ using CargoPacketID = PoolID; +using CargoPacketPool = Pool; /** The actual pool with cargo packets. */ extern CargoPacketPool _cargopacket_pool; diff --git a/src/core/pool_func.hpp b/src/core/pool_func.hpp index 9d33916f33..88668305f1 100644 --- a/src/core/pool_func.hpp +++ b/src/core/pool_func.hpp @@ -23,9 +23,9 @@ * @param type The return type of the method. */ #define DEFINE_POOL_METHOD(type) \ - template \ + template \ requires std::is_base_of_v \ - type Pool + type Pool /** * Create a clean pool. @@ -113,13 +113,6 @@ DEFINE_POOL_METHOD(inline void *)::AllocateItem(size_t size, size_t index) assert(sizeof(Titem) == size); 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(static_cast(item), 0, sizeof(Titem)); - } - } else if (Tzero) { - item = reinterpret_cast(CallocT(size)); } else { item = reinterpret_cast(MallocT(size)); } diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp index a258cc1b10..40184d72a1 100644 --- a/src/core/pool_type.hpp +++ b/src/core/pool_type.hpp @@ -126,10 +126,9 @@ private: * @tparam Tgrowth_step Size of growths; if the pool is full increase the size by this amount * @tparam Tpool_type Type of this pool * @tparam Tcache Whether to perform 'alloc' caching, i.e. don't actually free/malloc just reuse the memory - * @tparam Tzero Whether to zero the memory * @warning when Tcache is enabled *all* instances of this pool's item must be of the same size. */ -template +template requires std::is_base_of_v struct Pool : PoolBase { public: @@ -282,12 +281,12 @@ public: * Base class for all PoolItems * @tparam Tpool The pool this item is going to be part of */ - template *Tpool> + template *Tpool> struct PoolItem { Tindex index; ///< Index of this pool item /** Type of the pool this item is going to be part of */ - typedef struct Pool Pool; + typedef struct Pool Pool; /** * Allocates space for new Titem