diff --git a/Geo/CAD.cpp b/Geo/CAD.cpp index 87ffd4c76b9ce580e9d3923415ca35bb5538be46..ad2b1a916cef741580fedf6b2e0c116b698cbe11 100644 --- a/Geo/CAD.cpp +++ b/Geo/CAD.cpp @@ -1,4 +1,4 @@ -// $Id: CAD.cpp,v 1.22 2001-06-02 16:24:51 geuzaine Exp $ +// $Id: CAD.cpp,v 1.23 2001-06-07 14:20:08 remacle Exp $ #include "Gmsh.h" #include "Geo.h" @@ -1653,7 +1653,15 @@ Curve * CreateReversedCurve (Mesh *M,Curve *c){ newc->ubeg = 1. - c->uend; newc->uend = 1. - c->ubeg; End_Curve(newc); - Tree_Insert(M->Curves, &newc); + + Curve **pc; + + if(pc = (Curve**)Tree_PQuery(M->Curves,&newc)) + { + Free_Curve(&newc,0); + return *pc; + } + else Tree_Insert(M->Curves, &newc); return newc; } diff --git a/Mesh/3D_Coherence.cpp b/Mesh/3D_Coherence.cpp index f8eac619c62ba47b5530f134768007ee1f35e82f..5b59c7f9ceedbb7ccde9fe2913b1b8c2de2b3f7a 100644 --- a/Mesh/3D_Coherence.cpp +++ b/Mesh/3D_Coherence.cpp @@ -1,4 +1,4 @@ -// $Id: 3D_Coherence.cpp,v 1.14 2001-04-08 20:36:50 geuzaine Exp $ +// $Id: 3D_Coherence.cpp,v 1.15 2001-06-07 14:20:08 remacle Exp $ #include "Gmsh.h" #include "Const.h" @@ -232,6 +232,10 @@ void create_Fac (void *a, void *b){ void create_Faces (Volume * V){ + if(V->Faces) + { + Tree_Delete (V->Faces); + } V->Faces = Tree_Create (sizeof (Face), compareFace); FacesTree = V->Faces; Tree_Action (V->Simplexes, create_Fac); @@ -294,12 +298,27 @@ void create_Edge (void *a, void *b){ void create_Edges (Volume * V){ int i; Surface *S; + + // MEMORY LEAK (JF) + if(V->Edges) + { + Tree_Action(V->Edges,Free_Edge); + Tree_Delete(V->Edges); + } + V->Edges = Tree_Create (sizeof (Edge), compareedge); EdgesTree = V->Edges; Tree_Action (V->Simplexes, create_Edge); for (i = 0; i < List_Nbr (V->Surfaces); i++){ List_Read (V->Surfaces, i, &S); + // MEMORY LEAK (JF) + if(S->Edges) + { + // BUG BUG BUG (This causes crash) + //Tree_Action(S->Edges,Free_Edge); + Tree_Delete(S->Edges); + } S->Edges = Tree_Create (sizeof (Edge), compareedge); EdgesTree = S->Edges; Tree_Action (S->Simplexes, create_Edge); diff --git a/Mesh/3D_Extrude.cpp b/Mesh/3D_Extrude.cpp index e262b723d23b3e331ff680688c1bfed89395ba83..9d5153640d4921a230023bcac6be949fdbed5c8f 100644 --- a/Mesh/3D_Extrude.cpp +++ b/Mesh/3D_Extrude.cpp @@ -1,4 +1,4 @@ -// $Id: 3D_Extrude.cpp,v 1.9 2001-06-06 21:29:58 remacle Exp $ +// $Id: 3D_Extrude.cpp,v 1.10 2001-06-07 14:20:08 remacle Exp $ #include "Gmsh.h" #include "Const.h" @@ -337,6 +337,8 @@ void Extrude_Vertex (void *data, void *dum){ ep->Extrude (i, j + 1, newv->Pos.X, newv->Pos.Y, newv->Pos.Z); if (Vertex_Bound && (pV = (Vertex **) Tree_PQuery (Vertex_Bound, &newv))){ + // MEMORY LEAK (JF) + Free_Vertex (&newv,0); List_Add (v->Extruded_Points, pV); if (ToAdd) Tree_Insert (ToAdd, pV); @@ -505,7 +507,11 @@ void copy_mesh (Surface * from, Surface * to){ v1->Pos.X, v1->Pos.Y, v1->Pos.Z); if (Vertex_Bound && (pV = (Vertex **) Tree_PQuery (Vertex_Bound, &v1))) - v1 = *pV; + { + // MEMORY LEAK (JF) + Free_Vertex(&v1,0); + v1 = *pV; + } else{ Tree_Insert (THEM->Vertices, &v1); Tree_Insert (Vertex_Bound, &v1); @@ -520,7 +526,11 @@ void copy_mesh (Surface * from, Surface * to){ v2->Pos.X, v2->Pos.Y, v2->Pos.Z); if (Vertex_Bound && (pV = (Vertex **) Tree_PQuery (Vertex_Bound, &v2))) - v2 = *pV; + { + // MEMORY LEAK (JF) + Free_Vertex(&v2,0); + v2 = *pV; + } else{ Tree_Insert (THEM->Vertices, &v2); Tree_Insert (Vertex_Bound, &v2); @@ -535,7 +545,11 @@ void copy_mesh (Surface * from, Surface * to){ v3->Pos.X, v3->Pos.Y, v3->Pos.Z); if (Vertex_Bound && (pV = (Vertex **) Tree_PQuery (Vertex_Bound, &v3))) - v3 = *pV; + { + // MEMORY LEAK (JF) + Free_Vertex(&v3,0); + v3 = *pV; + } else{ Tree_Insert (THEM->Vertices, &v3); Tree_Insert (Vertex_Bound, &v3); diff --git a/Mesh/3D_Mesh.cpp b/Mesh/3D_Mesh.cpp index 7a28cd0049f41e041e886d8ff17e4289eceb9a78..a3e20b1fa5e1b227dcda51171ff3e58bef20d02f 100644 --- a/Mesh/3D_Mesh.cpp +++ b/Mesh/3D_Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: 3D_Mesh.cpp,v 1.19 2001-06-06 21:29:58 remacle Exp $ +// $Id: 3D_Mesh.cpp,v 1.20 2001-06-07 14:20:08 remacle Exp $ /* @@ -553,7 +553,8 @@ bool Bowyer_Watson (Mesh * m, Vertex * v, Simplex * S, int force){ List_Read (Simplexes_Destroyed, i, &s); if (!Tree_Suppress (m->Simplexes, &s)) Msg(GERROR, "Impossible to delete simplex"); - Free (s); + // CORRECTION FROM Free(s) to that + Free_Simplex (&s,0); } /* Creation des liens entre nouveaux simplexes */ diff --git a/Mesh/Create.cpp b/Mesh/Create.cpp index 18428a7c88811128fc4c8df4ff9c405f587f3692..92f1af057a93b568339e1a6021e7cbf8bbd1e01e 100644 --- a/Mesh/Create.cpp +++ b/Mesh/Create.cpp @@ -1,4 +1,4 @@ -// $Id: Create.cpp,v 1.19 2001-06-06 21:29:58 remacle Exp $ +// $Id: Create.cpp,v 1.20 2001-06-07 14:20:08 remacle Exp $ #include "Gmsh.h" #include "Const.h" @@ -561,12 +561,17 @@ void Free_Surface(void *a, void *b){ Tree_Action(pS->Simplexes, Free_Simplex); Tree_Delete(pS->Simplexes); List_Delete(pS->TrsfSimplexes); - Tree_Delete(pS->Vertices);//fait planter l'extrusion (1D-2D-1D boum) - //the vertices are freed globally before + Tree_Delete(pS->Vertices); List_Delete(pS->TrsfVertices); List_Delete(pS->Contours); List_Delete(pS->Control_Points); List_Delete(pS->Generatrices); + // MEMORY LEAK (JF) + if(pS->Edges) + { + Tree_Action(pS->Edges,Free_Edge); + Tree_Delete(pS->Edges); + } Free(pS); pS = NULL; } @@ -586,11 +591,13 @@ Volume * Create_Volume (int Num, int Typ, int Mat){ pV->Hexahedra = Tree_Create (sizeof (Hexahedron *), compareHexahedron); pV->Prisms = Tree_Create (sizeof (Prism *), comparePrism); pV->Extrude = NULL; + pV->Edges = NULL; + pV->Faces = NULL; return pV; } void Free_Volume(void *a, void *b){ - /* + Volume *pV = *(Volume**)a; if(pV){ List_Delete(pV->Surfaces); //surfaces freed elsewhere @@ -601,10 +608,19 @@ void Free_Volume(void *a, void *b){ Tree_Delete(pV->Hexahedra); Tree_Action(pV->Prisms, Free_Prism); Tree_Delete(pV->Prisms); + // MEMORY LEAK (JF) + if(pV->Edges) + { + Tree_Action(pV->Edges,Free_Edge); + Tree_Delete(pV->Edges); + } + if(pV->Faces) + { + Tree_Delete(pV->Faces); + } Free(pV); pV = NULL; - } - */ + } } Hexahedron * Create_Hexahedron (Vertex * v1, Vertex * v2, Vertex * v3, Vertex * v4, diff --git a/Mesh/Edge.h b/Mesh/Edge.h index a09fb8c5d6fb91734deeb805579b06a9e48b0791..e6f70741990f2e643a4b9408ab31dd23abded213 100644 --- a/Mesh/Edge.h +++ b/Mesh/Edge.h @@ -49,5 +49,6 @@ class EdgesContainer int compareedge (const void *a, const void *b); int compareedge_angle (const void *a, const void *b); +void Free_Edge(void *a, void *b); #endif diff --git a/Mesh/Generator.cpp b/Mesh/Generator.cpp index 37f52a8670063fbbdb8178ad7f56b7aed19b2982..89b76d18553e8d3babfe01b68f8b8d55b8e5d510 100644 --- a/Mesh/Generator.cpp +++ b/Mesh/Generator.cpp @@ -1,4 +1,4 @@ -// $Id: Generator.cpp,v 1.19 2001-06-06 21:29:58 remacle Exp $ +// $Id: Generator.cpp,v 1.20 2001-06-07 14:20:08 remacle Exp $ #include "Gmsh.h" #include "Const.h" @@ -136,7 +136,11 @@ void Init_Mesh (Mesh * M, int all){ Tree_Delete (M->VertexEdges); } if (M->Simplexes){ - Tree_Action (M->Simplexes, Free_Simplex);//produit des crashes innatendus... + // 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){ @@ -160,7 +164,7 @@ void Init_Mesh (Mesh * M, int all){ Tree_Delete (M->Surfaces); } if (M->Volumes){ - //Tree_Action (M->Volumes, Free_Volume);//produit des crashes innatendus... + Tree_Action (M->Volumes, Free_Volume);//produit des crashes innatendus... Tree_Delete (M->Volumes); } if (M->PhysicalGroups){