[vala] codegen: Fix freeing of GLists with null elements
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Fix freeing of GLists with null elements
- Date: Thu, 14 Oct 2010 13:43:10 +0000 (UTC)
commit fbd62577e03bd518aa1bed6dae18be43700108e1
Author: Jürg Billeter <j bitron ch>
Date: Thu Oct 14 15:38:54 2010 +0200
codegen: Fix freeing of GLists with null elements
Fixes bug 585341.
codegen/valaccodebasemodule.vala | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 209aaa9..2517c9a 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2652,6 +2652,29 @@ public class Vala.CCodeBaseModule : CodeGenerator {
elements_require_free = requires_destroy (type_arg);
if (elements_require_free) {
element_destroy_func_expression = get_destroy_func_expression (type_arg);
+
+ if (element_destroy_func_expression is CCodeIdentifier) {
+ var freeid = (CCodeIdentifier) element_destroy_func_expression;
+ string free0_func = "_%s0_".printf (freeid.name);
+
+ if (add_wrapper (free0_func)) {
+ var function = new CCodeFunction (free0_func, "void");
+ function.modifiers = CCodeModifiers.STATIC;
+
+ function.add_parameter (new CCodeFormalParameter ("var", "gpointer"));
+
+ push_function (function);
+
+ ccode.add_expression (get_unref_expression (new CCodeIdentifier ("var"), type_arg, null, true));
+
+ pop_function ();
+
+ cfile.add_function_declaration (function);
+ cfile.add_function (function);
+ }
+
+ element_destroy_func_expression = new CCodeIdentifier (free0_func);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]