From: Anthony Geay Date: Tue, 17 Aug 2021 08:26:22 +0000 (+0200) Subject: Memory leak hunting X-Git-Tag: V9_8_0a1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dc47eb9febee60af8ab97e56442d75b5d9f4c620;p=plugins%2Fblsurfplugin.git Memory leak hunting --- diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index e47c490..1b7cc8f 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -97,6 +97,9 @@ extern "C"{ #include #endif +#include +#include + using namespace std; /* ================================== @@ -2625,18 +2628,22 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, /* retrieve mesh data (see meshgems/mesh.h) */ integer nv, ne, nt, nq, vtx[4], tag, nb_tag; - integer *evedg, *evtri, *evquad, *tags_buff, type; + integer type; real xyz[3]; mesh_get_vertex_count (msh, &nv); mesh_get_edge_count (msh, &ne); mesh_get_triangle_count (msh, &nt); mesh_get_quadrangle_count(msh, &nq); - - evedg = (integer *)mesh_calloc_generic_buffer(msh); - evtri = (integer *)mesh_calloc_generic_buffer(msh); - evquad = (integer *)mesh_calloc_generic_buffer(msh); - tags_buff = (integer*)mesh_calloc_generic_buffer(msh); + + using deleted_unique_ptr = std::unique_ptr>; + + deleted_unique_ptr evedg_var((integer *)mesh_calloc_generic_buffer(msh), [](integer *ptr) { free(ptr); }); + deleted_unique_ptr evtri_var((integer *)mesh_calloc_generic_buffer(msh), [](integer *ptr) { free(ptr); }); + deleted_unique_ptr evquad_var((integer *)mesh_calloc_generic_buffer(msh), [](integer *ptr) { free(ptr); }); + deleted_unique_ptr tags_buff_var((integer*)mesh_calloc_generic_buffer(msh), [](integer *ptr) { free(ptr); }); + + integer *evedg(evedg_var.get()),*evtri(evtri_var.get()),*evquad(evquad_var.get()),*tags_buff(tags_buff_var.get()); std::vector nodes(nv+1); std::vector tags(nv+1);