diff options
author | Clark Barrett <barrett@cs.stanford.edu> | 2016-11-12 09:16:33 -0800 |
---|---|---|
committer | Clark Barrett <barrett@cs.stanford.edu> | 2016-11-12 09:19:45 -0800 |
commit | f5e33cfc8cabd5d66f184471f787a7cb8f8d3c6c (patch) | |
tree | 6577168d14b98824a6136c72970b2e8f367df497 /src/context | |
parent | 51beecbceb28f30004bda32e0babf201bd1f94d6 (diff) |
Fixed a bug in cdhashmap in which doubly-linked list was not properly cleaned up on a call to obliterate.
Also, removed some experimental code and a unit test from cdmap_black that used it. This test created a CDList *in* context memory which seems like a very bad idea (and
it was improperly implemented resulting in a memory leak).
Diffstat (limited to 'src/context')
-rw-r--r-- | src/context/cdhashmap.h | 22 | ||||
-rw-r--r-- | src/context/cdlist.h | 17 |
2 files changed, 3 insertions, 36 deletions
diff --git a/src/context/cdhashmap.h b/src/context/cdhashmap.h index 6ae74fbde..0a6c400a7 100644 --- a/src/context/cdhashmap.h +++ b/src/context/cdhashmap.h @@ -163,7 +163,7 @@ class CDOhash_map : public ContextObj { d_data = p->d_data; } } - // Explicitly call destructors for the key and the date as they will not + // Explicitly call destructors for the key and the data as they will not // otherwise get called. p->d_key.~Key(); p->d_data.~Data(); @@ -418,21 +418,6 @@ public: } } - // Use this for pointer data d allocated in context memory at this - // level. THIS IS HIGHLY EXPERIMENTAL. It seems to work if ALL - // your data objects are allocated from context memory. - void insertDataFromContextMemory(const Key& k, const Data& d) { - emptyTrash(); - - AlwaysAssert(d_map.find(k) == d_map.end()); - - Element* obj = new(d_context->getCMM()) Element(d_context, this, k, d, - false /* atLevelZero */, - true /* allocatedInCMM */); - - d_map[k] = obj; - } - /** * Version of insert() for CDHashMap<> that inserts data value d at * context level zero. This is a special escape hatch for inserting @@ -494,10 +479,9 @@ public: } else { d_first = elt->d_next; } - } else { - elt->d_prev->d_next = elt->d_next; - elt->d_next->d_prev = elt->d_prev; } + elt->d_prev->d_next = elt->d_next; + elt->d_next->d_prev = elt->d_prev; d_map.erase(j);//FIXME multithreading Debug("gc") << "key " << k << " obliterated zero-scope: " << elt << std::endl; if(!elt->d_noTrash) { diff --git a/src/context/cdlist.h b/src/context/cdlist.h index 4a5ebfd30..47667cc8d 100644 --- a/src/context/cdlist.h +++ b/src/context/cdlist.h @@ -238,23 +238,6 @@ public: } /** - * Main constructor: d_list starts as NULL, size is 0 - */ - CDList(bool allocatedInCMM, - Context* context, - bool callDestructor = true, - const CleanUp& cleanup = CleanUp(), - const Allocator& alloc = Allocator()) : - ContextObj(allocatedInCMM, context), - d_list(NULL), - d_size(0), - d_callDestructor(callDestructor), - d_sizeAlloc(0), - d_cleanUp(cleanup), - d_allocator(alloc) { - } - - /** * Destructor: delete the list */ ~CDList() { |