From 27bde8fab51e005c1344448a76d778ad58777323 Mon Sep 17 00:00:00 2001 From: Florent Lamiraux <florent@laas.fr> Date: Tue, 25 Jan 2011 22:14:30 +0100 Subject: [PATCH] Modify deallocation of poolStorage object in order to fix a memory bug. --- include/dynamic-graph/pool.h | 4 ++++ src/dgraph/pool.cpp | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/dynamic-graph/pool.h b/include/dynamic-graph/pool.h index 14deae3..a16844e 100644 --- a/include/dynamic-graph/pool.h +++ b/include/dynamic-graph/pool.h @@ -76,6 +76,10 @@ namespace dynamicgraph */ void deregisterEntity (const std::string& entname); + /*! \brief Unregister an entity. + \par[in] entity: iterator in the map, + */ + void deregisterEntity( const Entities::iterator& entity ); /*! \brief Get an entity. \par[in] entname: The name of the entity, \return Pointer towards the entity. diff --git a/src/dgraph/pool.cpp b/src/dgraph/pool.cpp index 3776a46..28eee63 100644 --- a/src/dgraph/pool.cpp +++ b/src/dgraph/pool.cpp @@ -48,11 +48,12 @@ PoolStorage:: { dgDEBUG(15) << "Delete \"" << (iter->first) <<"\""<<std::endl; - delete ((Entity*)iter->second); + Entity* entity = iter->second; + deregisterEntity(iter); + delete (entity); } dgDEBUGOUT(15); - return; } -- GitLab