[opengtl-commits] [148] * fix memory leaks in function declaration

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


Revision: 148
Author:   cyrille
Date:     2008-04-29 10:51:46 +0200 (Tue, 29 Apr 2008)

Log Message:
-----------
* fix memory leaks in function declaration
* VariableExpression doesn't own the variable object

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


Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp	2008-04-29 08:42:47 UTC (rev 147)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp	2008-04-29 08:51:46 UTC (rev 148)
@@ -74,7 +74,6 @@
 
 VariableExpression::~VariableExpression()
 {
-  delete m_variable;
   delete m_memberArray;
 }
 

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp	2008-04-29 08:42:47 UTC (rev 147)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp	2008-04-29 08:51:46 UTC (rev 148)
@@ -29,9 +29,9 @@
 #include <GTLCore/Type.h>
 #include <GTLCore/Type_p.h>
 #include <GTLCore/VariableNG_p.h>
-
 #include <GTLCore/Debug.h>
 #include <GTLCore/Function_p.h>
+#include <GTLCore/Utils_p.h>
 
 #include "Expression.h"
 #include "Statement.h"
@@ -43,6 +43,13 @@
   delete m_initialiser;
 }
 
+FunctionDeclaration::~FunctionDeclaration()
+{
+  deleteAll( m_parameters );
+  deleteAll( m_parametersVariable );
+  delete m_statement;
+}
+
 FunctionDeclaration::FunctionDeclaration(const GTLCore::ScopedName& _name, const GTLCore::Type* _returnType, std::vector< FunctionParameter* > _parameters ) : m_parameters(_parameters), m_statement(0)
 {
   int minimumParameters = -1; //_parameters.size() - 1;

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.h	2008-04-29 08:42:47 UTC (rev 147)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.h	2008-04-29 08:51:46 UTC (rev 148)
@@ -64,6 +64,7 @@
     class FunctionDeclaration {
       public:
         FunctionDeclaration( const GTLCore::ScopedName& _name, const GTLCore::Type* _returnType, std::vector< FunctionParameter* > _parameters );
+        ~FunctionDeclaration();
         Function* function();
         void setStatement( Statement* statement );
         const std::vector< GTLCore::VariableNG* >& parametersVariable() { return m_parametersVariable; }


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