From c358ccba3bf54a85ed9503b636c1f0bab381bc05 Mon Sep 17 00:00:00 2001 From: Tim King Date: Fri, 4 Dec 2015 15:58:19 -0800 Subject: [PATCH] Adding destructors for CDO an CDOhash_map in the restore() functions. --- src/context/cdhashmap.h | 6 +++++- src/context/cdo.h | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/context/cdhashmap.h b/src/context/cdhashmap.h index 51fd3b411..0eb1d03c9 100644 --- a/src/context/cdhashmap.h +++ b/src/context/cdhashmap.h @@ -128,8 +128,8 @@ class CDOhash_map : public ContextObj { } virtual void restore(ContextObj* data) { + CDOhash_map* p = static_cast(data); if(d_map != NULL) { - CDOhash_map* p = static_cast(data); if(p->d_map == NULL) { Assert(d_map->d_map.find(d_key) != d_map->d_map.end() && (*d_map->d_map.find(d_key)).second == this); @@ -163,6 +163,10 @@ class CDOhash_map : public ContextObj { d_data = p->d_data; } } + // Explicitly call destructors fro the key and the date as they will not + // otherwise get called. + p->d_key.~Key(); + p->d_data.~Data(); } /** ensure copy ctor is only called by us */ diff --git a/src/context/cdo.h b/src/context/cdo.h index 486626ae5..860648b27 100644 --- a/src/context/cdo.h +++ b/src/context/cdo.h @@ -70,8 +70,11 @@ protected: */ virtual void restore(ContextObj* pContextObj) { //Debug("context") << "restore cdo " << this; - d_data = ((CDO*) pContextObj)->d_data; + CDO* p = static_cast*>(pContextObj); + d_data = p->d_data; //Debug("context") << " to " << get() << std::endl; + // Explicitly call destructor as it will not otherwise get called. + p->d_data.~T(); } public: -- 2.30.2