aboutsummaryrefslogtreecommitdiff
path: root/tree.cpp
diff options
context:
space:
mode:
authorAdrian Kummerländer2012-04-15 00:26:12 +0200
committerAdrian Kummerländer2012-04-15 00:26:12 +0200
commit4daed5ebe3e8eae184a96055974ac15a3c55507f (patch)
tree900920a59780915d8b8eb75eccdf6afd45c680e0 /tree.cpp
parentde97f27c7aa3c74a40d5ba7ce9477d4bbdefbe8e (diff)
downloadSimpleParser-4daed5ebe3e8eae184a96055974ac15a3c55507f.tar
SimpleParser-4daed5ebe3e8eae184a96055974ac15a3c55507f.tar.gz
SimpleParser-4daed5ebe3e8eae184a96055974ac15a3c55507f.tar.bz2
SimpleParser-4daed5ebe3e8eae184a96055974ac15a3c55507f.tar.lz
SimpleParser-4daed5ebe3e8eae184a96055974ac15a3c55507f.tar.xz
SimpleParser-4daed5ebe3e8eae184a96055974ac15a3c55507f.tar.zst
SimpleParser-4daed5ebe3e8eae184a96055974ac15a3c55507f.zip
Removed all memory leaks detected by valgrind
Diffstat (limited to 'tree.cpp')
-rw-r--r--tree.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/tree.cpp b/tree.cpp
index 0ef3a39..29dbab1 100644
--- a/tree.cpp
+++ b/tree.cpp
@@ -69,11 +69,20 @@ Tree::Tree()
this->nodeCollection = new vector<Node*>();
}
+Tree::~Tree()
+{
+ for ( vector<Node*>::iterator it = this->nodeCollection->begin(); it != this->nodeCollection->end(); it++ )
+ {
+ delete *it;
+ }
+
+ delete this->nodeCollection;
+}
+
Node* Tree::addOperand(Node **place, double value)
{
OperandNode *newNode = new OperandNode();
- newNode = new OperandNode();
newNode->value = value;
this->nodeCollection->push_back( newNode );
@@ -89,7 +98,6 @@ Node* Tree::addOperator(Node **place, char oper)
{
OperatorNode *newNode = new OperatorNode();
- newNode = new OperatorNode();
newNode->function = oper;
this->nodeCollection->push_back( newNode );