[vala] Free local variables in GObject constructors



commit 17f120e67e71eea5716984e554505f5370f971ee
Author: Jürg Billeter <j bitron ch>
Date:   Wed Apr 1 22:08:31 2009 +0200

    Free local variables in GObject constructors
    
    Fixes bug 577641.
---
 gobject/valaccodemethodmodule.vala |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/gobject/valaccodemethodmodule.vala b/gobject/valaccodemethodmodule.vala
index 2a2fd30..bac46ec 100644
--- a/gobject/valaccodemethodmodule.vala
+++ b/gobject/valaccodemethodmodule.vala
@@ -269,7 +269,15 @@ internal class Vala.CCodeMethodModule : CCodeStructModule {
 						cblock.add_statement (stmt.ccodenode);
 					}
 				}
-				
+
+				foreach (LocalVariable local in m.body.get_local_variables ()) {
+					if (!local.floating && requires_destroy (local.variable_type)) {
+						var ma = new MemberAccess.simple (local.name);
+						ma.symbol_reference = local;
+						cblock.add_statement (new CCodeExpressionStatement (get_unref_expression (get_variable_cexpression (local.name), local.variable_type, ma)));
+					}
+				}
+
 				m.body.ccodenode = cblock;
 			}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]