From 9b40a9011850404d96c32f3f0c417150e1cc49a8 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Thu, 10 Oct 2024 19:27:02 +0800 Subject: [PATCH] fix --- .../geometry/file_parser/read_vtk_mesh.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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]); }