MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / Free

Method Free

modules/engine/graphics/src/d3d12/D3D12MemAlloc.cpp:1747–1768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1745
1746template<typename T>
1747void PoolAllocator<T>::Free(T* ptr)
1748{
1749 // Search all memory blocks to find ptr.
1750 for(size_t i = m_ItemBlocks.size(); i--; )
1751 {
1752 ItemBlock& block = m_ItemBlocks[i];
1753
1754 Item* pItemPtr;
1755 memcpy(&pItemPtr, &ptr, sizeof(pItemPtr));
1756
1757 // Check if pItemPtr is in address range of this block.
1758 if((pItemPtr >= block.pItems) && (pItemPtr < block.pItems + block.Capacity))
1759 {
1760 ptr->~T(); // Explicit destructor call.
1761 const UINT index = static_cast<UINT>(pItemPtr - block.pItems);
1762 pItemPtr->NextFreeIndex = block.FirstFreeIndex;
1763 block.FirstFreeIndex = index;
1764 return;
1765 }
1766 }
1767 D3D12MA_ASSERT(0 && "Pointer doesn't belong to this memory pool.");
1768}
1769
1770template<typename T>
1771typename PoolAllocator<T>::ItemBlock& PoolAllocator<T>::CreateNewBlock()

Callers 6

ClearMethod · 0.45
PopBackMethod · 0.45
PopFrontMethod · 0.45
RemoveMethod · 0.45
MergeBlockMethod · 0.45
NormalBlockClass · 0.45

Calls 12

memcpyFunction · 0.85
BinaryFindSortedFunction · 0.85
dropConstMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
pop_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
IsFreeMethod · 0.45

Tested by

no test coverage detected