diff --git a/include/irr/core/alloc/ContiguousPoolAddressAllocator.h b/include/irr/core/alloc/ContiguousPoolAddressAllocator.h index 1ed5052b3..3b0b0c958 100644 --- a/include/irr/core/alloc/ContiguousPoolAddressAllocator.h +++ b/include/irr/core/alloc/ContiguousPoolAddressAllocator.h @@ -39,7 +39,7 @@ class ContiguousPoolAddressAllocator : protected PoolAddressAllocator<_size_type ContiguousPoolAddressAllocator( void* reservedSpc, _size_type addressOffsetToApply, _size_type alignOffsetNeeded, _size_type maxAllocatableAlignment, size_type bufSz, size_type blockSz, void* dataBuf) noexcept : Base(reservedSpc,addressOffsetToApply,alignOffsetNeeded,maxAllocatableAlignment,bufSz,blockSz), - redirToAddress(Base::getFreeStack()+Base::reserved_size(*this,bufSz)/sizeof(size_type)), + redirToAddress(Base::freeStack+Base::reserved_size(*this,bufSz)/sizeof(size_type)), redirToMemory(redirToAddress+Base::blockCount), addressesAllocated(0u), dataBuffer(dataBuf) { selfOnlyReset(); @@ -103,7 +103,7 @@ class ContiguousPoolAddressAllocator : protected PoolAddressAllocator<_size_type assert(tmp>=Base::combinedOffset); #endif // _DEBUG // add allocated address back onto free stack - Base::getFreeStack()[Base::freeStackCtr++] = tmp; + Base::freeStack[Base::freeStackCtr++] = tmp; auto& redir = redirToMemory[Base::addressToBlockID(tmp)]; *(sortedRedirectsEnd++) = redir; #ifdef _DEBUG @@ -237,11 +237,10 @@ class ContiguousPoolAddressAllocator : protected PoolAddressAllocator<_size_type #ifdef _EXTREME_DEBUG inline void validateRedirects() const { - auto freeStack = Base::getFreeStack(); for (size_type i=0; i=Base::blockCount*Base::blockSize+Base::combinedOffset); - _IRR_BREAK_IF(redirToMemory[Base::addressToBlockID(freeStack[i])]!=invalid_address); + _IRR_BREAK_IF(Base::freeStack[i]>=Base::blockCount*Base::blockSize+Base::combinedOffset); + _IRR_BREAK_IF(redirToMemory[Base::addressToBlockID(Base::freeStack[i])]!=invalid_address); } size_type reportedAllocated=0; diff --git a/include/irr/core/alloc/PoolAddressAllocator.h b/include/irr/core/alloc/PoolAddressAllocator.h index aaffa9fff..ca7043d68 100644 --- a/include/irr/core/alloc/PoolAddressAllocator.h +++ b/include/irr/core/alloc/PoolAddressAllocator.h @@ -35,7 +35,8 @@ class PoolAddressAllocator : public AddressAllocatorBase(Base::reservedSpace)), freeStackCtr(0u) { reset(); } @@ -43,7 +44,8 @@ class PoolAddressAllocator : public AddressAllocatorBase PoolAddressAllocator(_size_type newBuffSz, PoolAddressAllocator&& other, Args&&... args) noexcept : - Base(std::move(other),std::forward(args)...), blockCount((newBuffSz-Base::alignOffset)/other.blockSize), blockSize(other.blockSize), freeStackCtr(0u) + Base(std::move(other),std::forward(args)...), + blockCount((newBuffSz-Base::alignOffset)/other.blockSize), blockSize(other.blockSize), freeStack(reinterpret_cast(Base::reservedSpace)), freeStackCtr(0u) { if (blockCount>other.blockCount) freeStackCtr = blockCount-other.blockCount; @@ -52,19 +54,18 @@ class PoolAddressAllocator : public AddressAllocatorBaseblockSize) return invalid_address; - return getFreeStack()[--freeStackCtr]; + return freeStack[--freeStackCtr]; } inline void free_addr(size_type addr, size_type bytes) noexcept @@ -91,12 +93,11 @@ class PoolAddressAllocator : public AddressAllocatorBase=Base::combinedOffset && (addr-Base::combinedOffset)%blockSize==0 && freeStackCtrsizeBound) sizeBound = allocSize; - auto freeStack = getFreeStack(); auto tmpStackCopy = freeStack+freeStackCtr; size_type boundedCount = 0; @@ -194,16 +194,8 @@ class PoolAddressAllocator : public AddressAllocatorBase(Base::reservedSpace); - } - inline const size_type* getFreeStack() const - { - return reinterpret_cast(Base::reservedSpace); - } };