[vala/0.48] codegen: Use detroy_value() for delete statement



commit b45db13d9307d271a5640175370ce5e042a701b3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Jul 12 07:43:32 2021 +0200

    codegen: Use detroy_value() for delete statement
    
    It is required to deal with special free functions here.
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/1201

 codegen/valaccodebasemodule.vala | 4 +---
 tests/pointers/delete.vala       | 5 +++++
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 28fe9150f..d3fd0457c 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4230,9 +4230,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        type = pointer_type.base_type;
                }
 
-               var ccall = new CCodeFunctionCall (get_destroy_func_expression (type));
-               ccall.add_argument (get_cvalue (stmt.expression));
-               ccode.add_expression (ccall);
+               ccode.add_expression (destroy_value (new GLibValue (type, get_cvalue (stmt.expression))));
        }
 
        static bool is_compact_class_destructor_call (Expression expr) {
diff --git a/tests/pointers/delete.vala b/tests/pointers/delete.vala
index f19dd859f..56565b4ba 100644
--- a/tests/pointers/delete.vala
+++ b/tests/pointers/delete.vala
@@ -13,4 +13,9 @@ void main () {
                Bar* bar = new Bar ();
                delete bar;
        }
+       {
+               StringBuilder* foo = new StringBuilder ();
+               foo->append ("foo");
+               delete foo;
+       }
 }


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