[opengtl-commits] [152] fix memory leaks in if/while/for statements

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 152
Author:   cyrille
Date:     2008-04-29 11:44:06 +0200 (Tue, 29 Apr 2008)

Log Message:
-----------
fix memory leaks in if/while/for statements

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.h


Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.cpp	2008-04-29 09:38:47 UTC (rev 151)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.cpp	2008-04-29 09:44:06 UTC (rev 152)
@@ -114,6 +114,11 @@
 //---------------------------------------------------//
 //------------------- IfStatement -------------------//
 //---------------------------------------------------//
+IfStatement::~IfStatement()
+{
+  delete m_expression;
+  delete m_ifStatement;
+}
 
 llvm::BasicBlock* IfStatement::generateStatement( GenerationContext& _context, llvm::BasicBlock* _bb ) const
 {
@@ -125,6 +130,13 @@
   return after;
 }
 
+IfElseStatement::~IfElseStatement()
+{
+  delete m_expression;
+  delete m_ifStatement;
+  delete m_elseStatement;
+}
+
 llvm::BasicBlock* IfElseStatement::generateStatement( GenerationContext& _context, llvm::BasicBlock* _bb) const
 {
   llvm::Value* test = m_expression->generateValue( _context, _bb ).value();
@@ -137,6 +149,14 @@
   return after;
 }
 
+ForStatement::~ForStatement()
+{
+  delete m_initStatement;
+  delete m_testExpression;
+  delete m_updateExpression;
+  delete m_forStatement;
+}
+
 llvm::BasicBlock* ForStatement::generateStatement( GenerationContext& _context, llvm::BasicBlock* _bb) const
 {
   llvm::BasicBlock* initBlock = m_initStatement->generateStatement( _context, _bb);
@@ -151,6 +171,12 @@
   return after;
 }
 
+WhileStatement::~WhileStatement()
+{
+  delete m_expression;
+  delete m_whileStatement;
+}
+
 llvm::BasicBlock* WhileStatement::generateStatement( GenerationContext& _context, llvm::BasicBlock* _bb) const
 {
   llvm::BasicBlock* testBlock = createBlock( _context );

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.h	2008-04-29 09:38:47 UTC (rev 151)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.h	2008-04-29 09:44:06 UTC (rev 152)
@@ -101,6 +101,7 @@
           m_expression( _expression), m_ifStatement( _ifStatement )
         {
         }
+        ~IfStatement();
         virtual llvm::BasicBlock* generateStatement( GenerationContext&, llvm::BasicBlock* ) const;
       private:
         Expression* m_expression;
@@ -116,6 +117,7 @@
           m_expression( _expression ), m_ifStatement(_ifStatement), m_elseStatement(_elseStatement)
         {
         }
+        ~IfElseStatement();
         virtual llvm::BasicBlock* generateStatement( GenerationContext&, llvm::BasicBlock* ) const;
       private:
         Expression* m_expression;
@@ -132,6 +134,7 @@
         : m_expression(_expression), m_whileStatement(_whileStatement)
         {
         }
+        ~WhileStatement();
         virtual llvm::BasicBlock* generateStatement( GenerationContext&, llvm::BasicBlock* ) const;
       private:
         Expression* m_expression;
@@ -146,6 +149,7 @@
         ForStatement( Statement* _initStatement, Expression* _testExpression, Expression* _updateExpression, Statement* _forStatement)
         : m_initStatement( _initStatement ), m_testExpression( _testExpression ), m_updateExpression(_updateExpression), m_forStatement( _forStatement )
         {}
+        ~ForStatement();
         virtual llvm::BasicBlock* generateStatement( GenerationContext&, llvm::BasicBlock* ) const;
       private:
         Statement* m_initStatement;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/