Skip to content

Commit

Permalink
Merge pull request ufz#1037 from rinkk/memfix20160212
Browse files Browse the repository at this point in the history
fixing memleak when generating regular prism mesh
  • Loading branch information
endJunction committed Feb 12, 2016
2 parents cc1e38a + df8a274 commit 3d40bc1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions MeshLib/MeshGenerators/MeshGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "MeshGenerator.h"

#include <memory>
#include <numeric>

#include "MeshLib/Node.h"
Expand Down Expand Up @@ -449,11 +450,11 @@ Mesh* MeshGenerator::generateRegularPrismMesh(
GeoLib::Point const& origin,
std::string const& mesh_name)
{
MeshLib::Mesh* mesh (
std::unique_ptr<MeshLib::Mesh> mesh (
generateRegularTriMesh(n_x_cells, n_y_cells, cell_size_x, cell_size_y, origin, mesh_name));
std::size_t const n_tris (mesh->getNElements());
for (std::size_t i=0; i<n_z_cells; ++i)
mesh = MeshLib::addTopLayerToMesh(*mesh, cell_size_z, mesh_name);
mesh.reset(MeshLib::addTopLayerToMesh(*mesh, cell_size_z, mesh_name));
std::vector<std::size_t> elem_ids (n_tris);
std::iota(elem_ids.begin(), elem_ids.end(), 0);
return MeshLib::removeElements(*mesh, elem_ids, mesh_name);
Expand Down

0 comments on commit 3d40bc1

Please sign in to comment.