From b95d4510980768a76187f93993eb464a7836da0c Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Mon, 10 Mar 2003 04:26:32 +0000 Subject: [PATCH] Fix crash due to identical vertex pointers in Mesh.Points and Mesh.Vertices --- Mesh/Generator.cpp | 77 ++++++++++++++++++++-------------------------- Mesh/Read_Mesh.cpp | 8 +++-- doc/VERSIONS | 5 +-- 3 files changed, 42 insertions(+), 48 deletions(-) diff --git a/Mesh/Generator.cpp b/Mesh/Generator.cpp index 0e1fbdaa34..2fe8ff3e72 100644 --- a/Mesh/Generator.cpp +++ b/Mesh/Generator.cpp @@ -1,4 +1,4 @@ -// $Id: Generator.cpp,v 1.39 2003-03-01 22:36:42 geuzaine Exp $ +// $Id: Generator.cpp,v 1.40 2003-03-10 04:26:32 geuzaine Exp $ // // Copyright (C) 1997 - 2003 C. Geuzaine, J.-F. Remacle // @@ -185,49 +185,38 @@ void Init_Mesh(Mesh * M, int all) ExitExtrude(); - if(M->Vertices) { - Tree_Action(M->Vertices, Free_Vertex); - Tree_Delete(M->Vertices); - } - if(M->VertexEdges) { - Tree_Action(M->VertexEdges, Free_Vertex); - Tree_Delete(M->VertexEdges); - } - if(M->Simplexes) { - // Tree_Action (M->Simplexes, Free_Simplex); //produit des crashes innatendus... - // normal, cette memoire est dupliquee - // dans les volumes. Je crois qu'on a besoin - // des 2, ce truc ne provoque pas de leaks. - Tree_Delete(M->Simplexes); - } - if(M->Points) { - Tree_Action(M->Points, Free_Vertex); - Tree_Delete(M->Points); - } - if(M->Curves) { - Tree_Action(M->Curves, Free_Curve); - Tree_Delete(M->Curves); - } - if(M->SurfaceLoops) { - //Tree_Action (M->SurfaceLoops, Free_SurfaceLoop); - Tree_Delete(M->SurfaceLoops); - } - if(M->EdgeLoops) { - //Tree_Action (M->EdgeLoops, Free_EdgeLoop); - Tree_Delete(M->EdgeLoops); - } - if(M->Surfaces) { - Tree_Action(M->Surfaces, Free_Surface); - Tree_Delete(M->Surfaces); - } - if(M->Volumes) { - Tree_Action(M->Volumes, Free_Volume); //produit des crashes innatendus... - Tree_Delete(M->Volumes); - } - if(M->PhysicalGroups) { - //Tree_Action (M->PhysicalGroups, Free_PhysicalGroup); - List_Delete(M->PhysicalGroups); - } + Tree_Action(M->Vertices, Free_Vertex); + Tree_Delete(M->Vertices); + + Tree_Action(M->VertexEdges, Free_Vertex); + Tree_Delete(M->VertexEdges); + + Tree_Action(M->Points, Free_Vertex); + Tree_Delete(M->Points); + + // Note: don't free the simplices here (with + // Tree_Action (M->Simplexes, Free_Simplex)): we free them + // in each curve, surface, volume + Tree_Delete(M->Simplexes); + + Tree_Action(M->Curves, Free_Curve); + Tree_Delete(M->Curves); + + //Tree_Action (M->SurfaceLoops, Free_SurfaceLoop); // todo + Tree_Delete(M->SurfaceLoops); + + //Tree_Action (M->EdgeLoops, Free_EdgeLoop); // todo + Tree_Delete(M->EdgeLoops); + + Tree_Action(M->Surfaces, Free_Surface); + Tree_Delete(M->Surfaces); + + Tree_Action(M->Volumes, Free_Volume); + Tree_Delete(M->Volumes); + + //Tree_Action (M->PhysicalGroups, Free_PhysicalGroup); // todo + List_Delete(M->PhysicalGroups); + if(M->Metric) { delete M->Metric; } diff --git a/Mesh/Read_Mesh.cpp b/Mesh/Read_Mesh.cpp index 89df548a54..16c8469ec9 100644 --- a/Mesh/Read_Mesh.cpp +++ b/Mesh/Read_Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: Read_Mesh.cpp,v 1.50 2003-03-01 22:36:42 geuzaine Exp $ +// $Id: Read_Mesh.cpp,v 1.51 2003-03-10 04:26:32 geuzaine Exp $ // // Copyright (C) 1997 - 2003 C. Geuzaine, J.-F. Remacle // @@ -316,7 +316,11 @@ void Read_Mesh_MSH(Mesh * M, FILE * File_GEO) M->Statistics[12]++; break; case PNT: - Tree_Replace(M->Points, &vertsp[0]); + // we need to make a new one: vertices in M->Vertices and + // M->Points should never point to the same memory location + vert = Create_Vertex(vertsp[0]->Num, vertsp[0]->Pos.X, vertsp[0]->Pos.Y, + vertsp[0]->Pos.Z, vertsp[0]->lc, vertsp[0]->w); + Tree_Replace(M->Points, &vert); break; default: Msg(WARNING, "Unknown type of element in Read_Mesh"); diff --git a/doc/VERSIONS b/doc/VERSIONS index f185b27f10..2f87af90fd 100644 --- a/doc/VERSIONS +++ b/doc/VERSIONS @@ -1,7 +1,8 @@ -$Id: VERSIONS,v 1.133 2003-03-07 18:35:56 geuzaine Exp $ +$Id: VERSIONS,v 1.134 2003-03-10 04:26:32 geuzaine Exp $ New in 1.42: suppressed the automatic addition of a ".geo" extension -if the file given on the command line is not recognized; +if the file given on the command line is not recognized; fixed various +small bugs; New in 1.41: Gmsh is now licensed under the GNU General Public License; general code cleanup (indent); -- GitLab