From: Tim King Date: Fri, 4 Dec 2015 23:58:19 +0000 (-0800) Subject: Adding destructors for CDO an CDOhash_map in the restore() functions. X-Git-Tag: cvc5-1.0.0~6140 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c358ccba3bf54a85ed9503b636c1f0bab381bc05;p=cvc5.git Adding destructors for CDO an CDOhash_map in the restore() functions. --- 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: