[opengtl-commits] [151] fix memory leaks in variable declaration and global data expression

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


Revision: 151
Author:   cyrille
Date:     2008-04-29 11:38:47 +0200 (Tue, 29 Apr 2008)

Log Message:
-----------
fix memory leaks in variable declaration and global data expression

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


Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp	2008-04-29 09:34:28 UTC (rev 150)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp	2008-04-29 09:38:47 UTC (rev 151)
@@ -62,6 +62,11 @@
 GlobalDataExpression::GlobalDataExpression( Expression* expression ) : m_expression( expression )
 { }
 
+GlobalDataExpression::~GlobalDataExpression()
+{
+  delete m_expression;
+}
+
 GTLCore::ExpressionResult GlobalDataExpression::generateValue( GenerationContext& _gc, llvm::BasicBlock* bb ) const
 {
   llvm::Constant* value = m_expression->generateValue( _gc, 0 ).constant();

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.h	2008-04-29 09:34:28 UTC (rev 150)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.h	2008-04-29 09:38:47 UTC (rev 151)
@@ -74,6 +74,7 @@
     class GlobalDataExpression : public Expression {
       public:
         GlobalDataExpression( Expression* expression );
+        ~GlobalDataExpression();
         virtual const GTLCore::Type* type() const { return m_expression->type(); }
         virtual bool isConstant() const { return true; }
         virtual GTLCore::ExpressionResult generateValue( GenerationContext& _gc, llvm::BasicBlock* bb ) const;

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.cpp	2008-04-29 09:34:28 UTC (rev 150)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.cpp	2008-04-29 09:38:47 UTC (rev 151)
@@ -74,6 +74,14 @@
   GTL_ASSERT( (not _initialSizes.empty() and type->dataType() == GTLCore::Type::ARRAY ) or _initialSizes.empty() );
 }
 
+VariableDeclaration::~VariableDeclaration()
+{
+  delete m_variable;
+  delete m_initialiser;
+  deleteAll( m_initialSizes );
+  delete m_functionInitialiser;
+}
+
 llvm::BasicBlock* VariableDeclaration::generateStatement( GenerationContext& _context, llvm::BasicBlock* _bb ) const
 {
   llvm::Value* initialiserValue = 0;

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.h	2008-04-29 09:34:28 UTC (rev 150)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Statement.h	2008-04-29 09:38:47 UTC (rev 151)
@@ -79,6 +79,7 @@
     {
       public:
         VariableDeclaration( const GTLCore::Type* _type, Expression* _initialiser, bool _constant, const std::list<Expression*>& _initialSizes);
+        ~VariableDeclaration();
       public:
         GTLCore::VariableNG* variable() { return m_variable; }
         void setFunctionIntialiser( AST::Statement* _functionInitialiser )


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