diff --git a/NineChess/src/MemoryPool.tcc b/NineChess/src/MemoryPool.tcc index 4f7f99d9..a6a966c5 100644 --- a/NineChess/src/MemoryPool.tcc +++ b/NineChess/src/MemoryPool.tcc @@ -39,11 +39,11 @@ const noexcept template MemoryPool::MemoryPool() noexcept +: currentBlock_(nullptr) +, currentSlot_(nullptr) +, lastSlot_(nullptr) +, freeSlots_(nullptr) { - currentBlock_ = nullptr; - currentSlot_ = nullptr; - lastSlot_ = nullptr; - freeSlots_ = nullptr; } @@ -59,12 +59,12 @@ MemoryPool() template MemoryPool::MemoryPool(MemoryPool&& memoryPool) noexcept +: currentBlock_(memoryPool.currentBlock_) +, currentSlot_(memoryPool.currentSlot_) +, lastSlot_(memoryPool.lastSlot_) +, freeSlots_(memoryPool.freeSlots) { - currentBlock_ = memoryPool.currentBlock_; memoryPool.currentBlock_ = nullptr; - currentSlot_ = memoryPool.currentSlot_; - lastSlot_ = memoryPool.lastSlot_; - freeSlots_ = memoryPool.freeSlots_; } @@ -133,16 +133,14 @@ void MemoryPool::allocateBlock() { // Allocate space for the new block and store a pointer to the previous one - data_pointer_ newBlock = reinterpret_cast - (operator new(BlockSize)); + data_pointer_ newBlock = reinterpret_cast(operator new(BlockSize)); reinterpret_cast(newBlock)->next = currentBlock_; currentBlock_ = reinterpret_cast(newBlock); - // Pad block body to staisfy the alignment requirements for elements + // Pad block body to satisfy the alignment requirements for elements data_pointer_ body = newBlock + sizeof(slot_pointer_); size_type bodyPadding = padPointer(body, alignof(slot_type_)); currentSlot_ = reinterpret_cast(body + bodyPadding); - lastSlot_ = reinterpret_cast - (newBlock + BlockSize - sizeof(slot_type_) + 1); + lastSlot_ = reinterpret_cast(newBlock + BlockSize - sizeof(slot_type_) + 1); }