From 1df86d534849429e269eeea9be914a3df5abd8ea Mon Sep 17 00:00:00 2001 From: Tim King Date: Mon, 1 Feb 2016 10:56:55 -0800 Subject: [PATCH] Fixing a memory leak in array info. --- src/theory/arrays/array_info.cpp | 27 +++++++++++++++++++++++---- src/theory/arrays/array_info.h | 21 ++------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/theory/arrays/array_info.cpp b/src/theory/arrays/array_info.cpp index e94abe9cb..acc73163c 100644 --- a/src/theory/arrays/array_info.cpp +++ b/src/theory/arrays/array_info.cpp @@ -23,6 +23,27 @@ namespace CVC4 { namespace theory { namespace arrays { +Info::Info(context::Context* c, Backtracker* bck) + : isNonLinear(c, false), + rIntro1Applied(c, false), + modelRep(c,TNode()), + constArr(c,TNode()), + weakEquivPointer(c,TNode()), + weakEquivIndex(c,TNode()), + weakEquivSecondary(c,TNode()), + weakEquivSecondaryReason(c,TNode()) +{ + indices = new(true)CTNodeList(c); + stores = new(true)CTNodeList(c); + in_stores = new(true)CTNodeList(c); +} + +Info::~Info() { + indices->deleteSelf(); + stores->deleteSelf(); + in_stores->deleteSelf(); +} + ArrayInfo::ArrayInfo(context::Context* c, Backtracker* b) : ct(c), bck(b), info_map(), d_mergeInfoTimer("theory::arrays::mergeInfoTimer"), @@ -115,11 +136,9 @@ void ArrayInfo::addIndex(const Node a, const TNode i) { CNodeInfoMap::iterator it = info_map.find(a); if(it == info_map.end()) { - temp_indices = new(true) CTNodeList(ct); - temp_indices->push_back(i); - temp_info = new Info(ct, bck); - temp_info->indices = temp_indices; + temp_indices = temp_info->indices; + temp_indices->push_back(i); info_map[a] = temp_info; } else { temp_indices = (*it).second->indices; diff --git a/src/theory/arrays/array_info.h b/src/theory/arrays/array_info.h index 3e479e0f9..319864c34 100644 --- a/src/theory/arrays/array_info.h +++ b/src/theory/arrays/array_info.h @@ -74,25 +74,8 @@ public: CTNodeList* stores; CTNodeList* in_stores; - Info(context::Context* c, Backtracker* bck) - : isNonLinear(c, false), - rIntro1Applied(c, false), - modelRep(c,TNode()), - constArr(c,TNode()), - weakEquivPointer(c,TNode()), - weakEquivIndex(c,TNode()), - weakEquivSecondary(c,TNode()), - weakEquivSecondaryReason(c,TNode()) { - indices = new(true)CTNodeList(c); - stores = new(true)CTNodeList(c); - in_stores = new(true)CTNodeList(c); - } - - ~Info() { - indices->deleteSelf(); - stores->deleteSelf(); - in_stores->deleteSelf(); - } + Info(context::Context* c, Backtracker* bck); + ~Info(); /** * prints the information -- 2.30.2