From 3ac94bd6d8de507a3ebe5261cad33a0f66de46a2 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 11 Nov 2013 15:07:38 +0100 Subject: [PATCH] Fix a valgrind warning about mismatched free() --- xs/src/TriangleMesh.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xs/src/TriangleMesh.cpp b/xs/src/TriangleMesh.cpp index 134c52945..bc653d8ec 100644 --- a/xs/src/TriangleMesh.cpp +++ b/xs/src/TriangleMesh.cpp @@ -27,19 +27,19 @@ TriangleMesh::TriangleMesh(const TriangleMesh &other) this->stl.heads = NULL; this->stl.tail = NULL; if (other.stl.facet_start != NULL) { - this->stl.facet_start = new stl_facet[other.stl.stats.number_of_facets]; + this->stl.facet_start = (stl_facet*)calloc(other.stl.stats.number_of_facets, sizeof(stl_facet)); std::copy(other.stl.facet_start, other.stl.facet_start + other.stl.stats.number_of_facets, this->stl.facet_start); } if (other.stl.neighbors_start != NULL) { - this->stl.neighbors_start = new stl_neighbors[other.stl.stats.number_of_facets]; + this->stl.neighbors_start = (stl_neighbors*)calloc(other.stl.stats.number_of_facets, sizeof(stl_neighbors)); std::copy(other.stl.neighbors_start, other.stl.neighbors_start + other.stl.stats.number_of_facets, this->stl.neighbors_start); } if (other.stl.v_indices != NULL) { - this->stl.v_indices = new v_indices_struct[other.stl.stats.number_of_facets]; + this->stl.v_indices = (v_indices_struct*)calloc(other.stl.stats.number_of_facets, sizeof(v_indices_struct)); std::copy(other.stl.v_indices, other.stl.v_indices + other.stl.stats.number_of_facets, this->stl.v_indices); } if (other.stl.v_shared != NULL) { - this->stl.v_shared = new stl_vertex[other.stl.stats.shared_vertices]; + this->stl.v_shared = (stl_vertex*)calloc(other.stl.stats.shared_vertices, sizeof(stl_vertex)); std::copy(other.stl.v_shared, other.stl.v_shared + other.stl.stats.shared_vertices, this->stl.v_shared); } }