summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/context/cdhashmap.h6
-rw-r--r--src/context/cdo.h5
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<CDOhash_map*>(data);
if(d_map != NULL) {
- CDOhash_map* p = static_cast<CDOhash_map*>(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<T>*) pContextObj)->d_data;
+ CDO<T>* p = static_cast<CDO<T>*>(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:
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback