MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator / resize

Method resize

include/vk_mem_alloc.h:4824–4847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4822
4823template<typename T, typename AllocatorT>
4824void VmaVector<T, AllocatorT>::resize(size_t newCount)
4825{
4826 size_t newCapacity = m_Capacity;
4827 if (newCount > m_Capacity)
4828 {
4829 newCapacity = VMA_MAX(newCount, VMA_MAX(m_Capacity * 3 / 2, (size_t)8));
4830 }
4831
4832 if (newCapacity != m_Capacity)
4833 {
4834 VMA_HEAVY_ASSERT(newCapacity > 0);
4835 T* const newArray = VmaAllocateArray<T>(m_Allocator.m_pCallbacks, newCapacity);
4836 const size_t elementsToCopy = VMA_MIN(m_Count, newCount);
4837 if (elementsToCopy != 0)
4838 {
4839 memcpy(newArray, m_pArray, elementsToCopy * sizeof(T));
4840 }
4841 VmaFree(m_Allocator.m_pCallbacks, m_pArray);
4842 m_Capacity = newCapacity;
4843 m_pArray = newArray;
4844 }
4845
4846 m_Count = newCount;
4847}
4848
4849template<typename T, typename AllocatorT>
4850void VmaVector<T, AllocatorT>::shrink_to_fit()

Callers 8

LoadShaderFunction · 0.80
CreateSwapchainFunction · 0.80
InitMethod · 0.80
ReadFileFunction · 0.80
initResizableFunction · 0.80
AddMethod · 0.80
CleanupAfterFreeMethod · 0.80

Calls 3

VmaFreeFunction · 0.85
shrink_to_fitMethod · 0.80
dataMethod · 0.45

Tested by 2

InitMethod · 0.64