| 4782 | |
| 4783 | template<typename T> |
| 4784 | void VmaPoolAllocator<T>::Free(T* ptr) |
| 4785 | { |
| 4786 | // Search all memory blocks to find ptr. |
| 4787 | for (size_t i = m_ItemBlocks.size(); i--; ) |
| 4788 | { |
| 4789 | ItemBlock& block = m_ItemBlocks[i]; |
| 4790 | |
| 4791 | // Casting to union. |
| 4792 | Item* pItemPtr; |
| 4793 | memcpy(&pItemPtr, &ptr, sizeof(pItemPtr)); |
| 4794 | |
| 4795 | // Check if pItemPtr is in address range of this block. |
| 4796 | if ((pItemPtr >= block.pItems) && (pItemPtr < block.pItems + block.Capacity)) |
| 4797 | { |
| 4798 | ptr->~T(); // Explicit destructor call. |
| 4799 | const uint32_t index = static_cast<uint32_t>(pItemPtr - block.pItems); |
| 4800 | pItemPtr->NextFreeIndex = block.FirstFreeIndex; |
| 4801 | block.FirstFreeIndex = index; |
| 4802 | return; |
| 4803 | } |
| 4804 | } |
| 4805 | VMA_ASSERT(0 && "Pointer doesn't belong to this memory pool."); |
| 4806 | } |
| 4807 | |
| 4808 | template<typename T> |
| 4809 | typename VmaPoolAllocator<T>::ItemBlock& VmaPoolAllocator<T>::CreateNewBlock() |
no test coverage detected