Skip to content
Snippets Groups Projects
Commit 281cfb04 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fix memory bugs
parent bd99f6c5
Branches
Tags
No related merge requests found
// $Id: GModel.cpp,v 1.51 2008-01-14 21:29:13 remacle Exp $
// $Id: GModel.cpp,v 1.52 2008-01-16 20:25:39 geuzaine Exp $
//
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
//
......@@ -56,28 +56,33 @@ GModel *GModel::current()
void GModel::destroy()
{
std::vector<GFace*> to_keep;
for(riter it = firstRegion(); it != lastRegion(); ++it)
delete *it;
regions.clear();
std::vector<GFace*> to_keep;
for(fiter it = firstFace(); it != lastFace(); ++it){
// projection faces are persistent
if((*it)->geomType() == GEntity::ProjectionFace)
if((*it)->getNativeType() == GEntity::UnknownModel &&
(*it)->geomType() == GEntity::ProjectionFace)
to_keep.push_back(*it);
else
delete *it;
}
faces.clear();
faces.insert(to_keep.begin(), to_keep.end());
for(eiter it = firstEdge(); it != lastEdge(); ++it)
delete *it;
edges.clear();
for(viter it = firstVertex(); it != lastVertex(); ++it)
delete *it;
vertices.clear();
if(normals) delete normals;
normals = 0;
MVertex::resetGlobalNumber();
MElement::resetGlobalNumber();
gmshSurface::reset();
......
// $Id: OpenFile.cpp,v 1.165 2008-01-08 12:05:45 geuzaine Exp $
// $Id: OpenFile.cpp,v 1.166 2008-01-16 20:25:39 geuzaine Exp $
//
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
//
......@@ -261,6 +261,7 @@ void SetProjectName(const char *name)
char no_ext[256], ext[256], base[256];
SplitFileName(name, no_ext, ext, base);
if(CTX.filename != name) // yes, we mean to compare the pointers
strncpy(CTX.filename, name, 255);
strncpy(CTX.no_ext_filename, no_ext, 255);
strncpy(CTX.base_filename, base, 255);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment