diff options
author | Morgan Deters <mdeters@gmail.com> | 2010-08-17 05:06:09 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2010-08-17 05:06:09 +0000 |
commit | daf715e2ccb53bd88c6f374840b5d41e72c61c90 (patch) | |
tree | d868168b9ae9fc6fd4797f361d3596e3bd3197fc | |
parent | 229ab1aca6e89315a07899b093951d8f4f9d0c02 (diff) |
Add "no trash" CDMap elements, so that CDMap elements can themselves
be allocated in context memory. CDMap black-box test extended.
-rw-r--r-- | src/context/cdmap.h | 12 | ||||
-rw-r--r-- | test/unit/context/cdmap_black.h | 14 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/context/cdmap.h b/src/context/cdmap.h index 66f897818..c218d05f3 100644 --- a/src/context/cdmap.h +++ b/src/context/cdmap.h @@ -329,7 +329,9 @@ public: ++i) { // mark it as being a destruction (short-circuit restore()) (*i).second->d_map = NULL; - (*i).second->deleteSelf(); + if(!(*i).second->d_noTrash) { + (*i).second->deleteSelf(); + } } d_map.clear(); d_first = NULL; @@ -349,7 +351,9 @@ public: ++i) { // mark it as being a destruction (short-circuit restore()) (*i).second->d_map = NULL; - (*i).second->deleteSelf(); + if(!(*i).second->d_noTrash) { + (*i).second->deleteSelf(); + } } d_map.clear(); d_first = NULL; @@ -486,7 +490,9 @@ public: d_map.erase(j);//FIXME multithreading Debug("gc") << "key " << k << " obliterated zero-scope: " << elt << std::endl; // was already destructed, so don't call ->deleteSelf() - ::operator delete(elt); + if(!elt->d_noTrash) { + ::operator delete(elt); + } } } } diff --git a/test/unit/context/cdmap_black.h b/test/unit/context/cdmap_black.h index 7b8953dc0..37beb5054 100644 --- a/test/unit/context/cdmap_black.h +++ b/test/unit/context/cdmap_black.h @@ -930,9 +930,8 @@ public: }; void testMapOfLists() { - try{ - //Debug.on("gc"); - //Debug.on("context"); + //Debug.on("gc"); + //Debug.on("context"); CDMap<int, CDList<myint>*, int_hasher> map(d_context); @@ -1055,6 +1054,13 @@ public: } TS_ASSERT(d_context->getLevel() == 0); - } catch(Exception& e) { cout << e << std::endl; throw e; } + } + + void testCmmElementsAtLevel0() { + // this was crashing + + CDMap<int, int*, int_hasher> map(d_context); + int* a = (int*)d_context->getCMM()->newData(sizeof(int)); + map.insertDataFromContextMemory(1, a); } }; |