[opengtl-commits] [149] fix memory leaks in ReturnStatement and PrintStatement

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


Revision: 149
Author:   cyrille
Date:     2008-04-29 10:55:48 +0200 (Tue, 29 Apr 2008)

Log Message:
-----------
fix memory leaks in ReturnStatement and PrintStatement

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 08:51:46 UTC (rev 148)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.cpp	2008-04-29 08:55:48 UTC (rev 149)
@@ -154,6 +154,11 @@
   return after;
 }
 
+ReturnStatement::~ReturnStatement()
+{
+  delete m_returnExpr;
+}
+
 llvm::BasicBlock* ReturnStatement::generateStatement( GenerationContext& _context, llvm::BasicBlock* _bb) const
 { // TODO move to the code generator ?
   if( m_returnExpr )
@@ -169,6 +174,11 @@
   return _bb;
 }
 
+PrintStatement::~PrintStatement()
+{
+  deleteAll( m_expressions );
+}
+
 llvm::BasicBlock* PrintStatement::generateStatement( GenerationContext& _context, llvm::BasicBlock* _bb ) const
 {
   std::vector<const llvm::Type*> params;

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.h	2008-04-29 08:51:46 UTC (rev 148)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.h	2008-04-29 08:55:48 UTC (rev 149)
@@ -161,6 +161,7 @@
         ReturnStatement( Expression* _returnExpr ) : m_returnExpr( _returnExpr )
         {
         }
+        ~ReturnStatement();
         virtual llvm::BasicBlock* generateStatement( GenerationContext&, llvm::BasicBlock* ) const;
       private:
         Expression* m_returnExpr;
@@ -174,6 +175,7 @@
         PrintStatement( const std::list<AST::Expression*>& _expressions) : m_expressions(_expressions)
         {
         }
+        ~PrintStatement();
         virtual llvm::BasicBlock* generateStatement( GenerationContext&, llvm::BasicBlock* ) const;
       private:
         std::list<AST::Expression*> m_expressions;


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