diff --git a/code/ImproveCacheLocality.cpp b/code/ImproveCacheLocality.cpp index 9075fd196..bfe77ae2c 100644 --- a/code/ImproveCacheLocality.cpp +++ b/code/ImproveCacheLocality.cpp @@ -206,10 +206,8 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh // create a copy of the piNumTriPtr buffer unsigned int* const piNumTriPtr = adj.mLiveTriangles; - const unsigned int* const piNumTriPtrNoModify = new unsigned int[pMesh->mNumVertices]; - memcpy(const_cast (piNumTriPtrNoModify),piNumTriPtr, - pMesh->mNumVertices * sizeof(unsigned int)); - + const std::vector piNumTriPtrNoModify(piNumTriPtr, piNumTriPtr + pMesh->mNumVertices); + // get the largest number of referenced triangles and allocate the "candidate buffer" unsigned int iMaxRefTris = 0; { const unsigned int* piCur = adj.mLiveTriangles; @@ -377,6 +375,6 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh delete[] piCachingStamps; delete[] piIBOutput; delete[] piCandidates; - delete[] piNumTriPtrNoModify; + return fACMR2; }