forked from OSchip/llvm-project
Clean up the ownership model a bit so that nodes actually get deleted more
frequently. This still leaks edges quite a bit, but it leaks no nodes (I think). llvm-svn: 2190
This commit is contained in:
parent
ad4ef851b0
commit
6c1a58d6ba
|
@ -168,6 +168,9 @@ SchedGraphNode::SchedGraphNode(unsigned int _nodeId,
|
||||||
/*dtor*/
|
/*dtor*/
|
||||||
SchedGraphNode::~SchedGraphNode()
|
SchedGraphNode::~SchedGraphNode()
|
||||||
{
|
{
|
||||||
|
// for each node, delete its out-edges
|
||||||
|
std::for_each(beginOutEdges(), endOutEdges(),
|
||||||
|
deleter<SchedGraphEdge>);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SchedGraphNode::dump(int indent=0) const {
|
void SchedGraphNode::dump(int indent=0) const {
|
||||||
|
@ -233,16 +236,9 @@ SchedGraph::SchedGraph(const BasicBlock* bb,
|
||||||
SchedGraph::~SchedGraph()
|
SchedGraph::~SchedGraph()
|
||||||
{
|
{
|
||||||
for (const_iterator I = begin(); I != end(); ++I)
|
for (const_iterator I = begin(); I != end(); ++I)
|
||||||
{
|
delete I->second;
|
||||||
SchedGraphNode *node = I->second;
|
delete graphRoot;
|
||||||
|
delete graphLeaf;
|
||||||
// for each node, delete its out-edges
|
|
||||||
std::for_each(node->beginOutEdges(), node->endOutEdges(),
|
|
||||||
deleter<SchedGraphEdge>);
|
|
||||||
|
|
||||||
// then delete the node itself.
|
|
||||||
delete node;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -967,8 +963,8 @@ SchedGraphSet::SchedGraphSet(const Function* _function,
|
||||||
SchedGraphSet::~SchedGraphSet()
|
SchedGraphSet::~SchedGraphSet()
|
||||||
{
|
{
|
||||||
// delete all the graphs
|
// delete all the graphs
|
||||||
for (const_iterator I = begin(); I != end(); ++I)
|
for(iterator I = begin(), E = end(); I != E; ++I)
|
||||||
delete *I;
|
delete *I; // destructor is a friend
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue