[vala/0.44] codegen: Don't create special GArray clear-func for non-null structs



commit 534b028bcb5167daa76dc3ed739816e5a5caf697
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Mar 10 21:51:02 2019 +0100

    codegen: Don't create special GArray clear-func for non-null structs
    
    Based on patch by Jakub Kaszycki

 codegen/valaccodebasemodule.vala | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 454445746..5e0ff4c8e 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5126,10 +5126,15 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        if (cl == garray_type) {
                                var type_arg = expr.type_reference.get_type_arguments ().get (0);
                                if (requires_destroy (type_arg)) {
-                                       var free_wrapper = generate_destroy_function_content_of_wrapper 
(type_arg);
                                        var clear_func = new CCodeFunctionCall (new CCodeIdentifier 
("g_array_set_clear_func"));
                                        clear_func.add_argument (get_cvalue_ (expr.target_value));
-                                       clear_func.add_argument (new CCodeIdentifier (free_wrapper));
+                                       string destroy_func;
+                                       if (type_arg.is_non_null_simple_type () || 
type_arg.is_real_non_null_struct_type ()) {
+                                               destroy_func = get_ccode_destroy_function 
(type_arg.data_type);
+                                       } else {
+                                               destroy_func = generate_destroy_function_content_of_wrapper 
(type_arg);
+                                       }
+                                       clear_func.add_argument (new CCodeCastExpression (new CCodeIdentifier 
(destroy_func), "GDestroyNotify"));
                                        ccode.add_expression (clear_func);
                                }
                        }


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