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

Method resize

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

Source from the content-addressed store, hash-verified

1064
1065template<typename T>
1066void Vector<T>::resize(size_t newCount, bool freeMemory)
1067{
1068 size_t newCapacity = m_Capacity;
1069 if (newCount > m_Capacity)
1070 {
1071 newCapacity = D3D12MA_MAX(newCount, D3D12MA_MAX(m_Capacity * 3 / 2, (size_t)8));
1072 }
1073 else if (freeMemory)
1074 {
1075 newCapacity = newCount;
1076 }
1077
1078 if (newCapacity != m_Capacity)
1079 {
1080 T* const newArray = newCapacity ? AllocateArray<T>(m_AllocationCallbacks, newCapacity) : NULL;
1081 const size_t elementsToCopy = D3D12MA_MIN(m_Count, newCount);
1082 if (elementsToCopy != 0)
1083 {
1084 memcpy(newArray, m_pArray, elementsToCopy * sizeof(T));
1085 }
1086 Free(m_AllocationCallbacks, m_pArray);
1087 m_Capacity = newCapacity;
1088 m_pArray = newArray;
1089 }
1090
1091 m_Count = newCount;
1092}
1093
1094template<typename T>
1095void Vector<T>::insert(size_t index, const T& src)

Callers 2

AddMethod · 0.45
CleanupAfterFreeMethod · 0.45

Calls 4

D3D12MA_MAXFunction · 0.85
D3D12MA_MINFunction · 0.85
memcpyFunction · 0.85
FreeFunction · 0.85

Tested by

no test coverage detected