diff --git a/projects/CuLagrange/geometry/file_parser/read_vtk_mesh.hpp b/projects/CuLagrange/geometry/file_parser/read_vtk_mesh.hpp index 9a0e3648fe..553595ccb1 100644 --- a/projects/CuLagrange/geometry/file_parser/read_vtk_mesh.hpp +++ b/projects/CuLagrange/geometry/file_parser/read_vtk_mesh.hpp @@ -454,15 +454,15 @@ namespace zeno { std::vector read_attr_vec3f(std::ifstream &file, int num_points, bool type_float) { std::vector res(num_points); if (type_float) { - float* data = new float[num_points * 3]; - file.read((char*)data, sizeof (float) * num_points * 3); + std::vector data(num_points * 3); + file.read((char*)data.data(), sizeof (float) * num_points * 3); for (auto i = 0; i < num_points * 3; i++) { reinterpret_cast(res.data())[i] = byteswap(data[i]); } } else { - double* data = new double[num_points * 3]; - file.read((char*)data, sizeof (double) * num_points * 3); + std::vector data(num_points * 3); + file.read((char*)data.data(), sizeof (double) * num_points * 3); for (auto i = 0; i < num_points * 3; i++) { reinterpret_cast(res.data())[i] = byteswap(data[i]); } @@ -472,15 +472,15 @@ namespace zeno { std::vector read_attr_float(std::ifstream &file, int num_points, bool type_float) { std::vector res(num_points); if (type_float) { - float* data = new float[num_points]; - file.read((char*)data, sizeof (float) * num_points); + std::vector data(num_points); + file.read((char*)data.data(), sizeof (float) * num_points); for (auto i = 0; i < num_points; i++) { reinterpret_cast(res.data())[i] = byteswap(data[i]); } } else { - double* data = new double[num_points]; - file.read((char*)data, sizeof (double) * num_points); + std::vector data(num_points); + file.read((char*)data.data(), sizeof (double) * num_points); for (auto i = 0; i < num_points; i++) { reinterpret_cast(res.data())[i] = byteswap(data[i]); }