]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use alternative for g_free in POSIX profile
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 18 Oct 2019 22:12:26 +0000 (00:12 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 19 Oct 2019 08:20:52 +0000 (10:20 +0200)
codegen/valaccodearraymodule.vala
codegen/valaccodebasemodule.vala

index e609a10314c49e88ee719983a7a9926d1d1dc6f5..e71f41d70e8ba0ff1182d04999cb42ef32843aad 100644 (file)
@@ -243,7 +243,12 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 
                ccode.close ();
 
-               var carrfree = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
+               CCodeFunctionCall carrfree;
+               if (context.profile == Profile.POSIX) {
+                       carrfree = new CCodeFunctionCall (new CCodeIdentifier ("free"));
+               } else {
+                       carrfree = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
+               }
                carrfree.add_argument (new CCodeIdentifier ("array"));
                ccode.add_expression (carrfree);
 
@@ -316,7 +321,12 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
                ccall.add_argument (new CCodeIdentifier ("destroy_func"));
                ccode.add_expression (ccall);
 
-               var carrfree = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
+               CCodeFunctionCall carrfree;
+               if (context.profile == Profile.POSIX) {
+                       carrfree = new CCodeFunctionCall (new CCodeIdentifier ("free"));
+               } else {
+                       carrfree = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
+               }
                carrfree.add_argument (new CCodeIdentifier ("array"));
                ccode.add_expression (carrfree);
 
index ddce144e1ad823e317404dcb82d8a11a755ee908..d3f4f416db7f2087ab89aefdae6cf1a721e7b7e9 100644 (file)
@@ -3200,7 +3200,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                ccode.add_expression (destroy_call);
                        }
 
-                       var free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
+                       CCodeFunctionCall free_call;
+                       if (context.profile == Profile.POSIX) {
+                               free_call = new CCodeFunctionCall (new CCodeIdentifier ("free"));
+                       } else {
+                               free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
+                       }
                        free_call.add_argument (new CCodeIdentifier ("self"));
 
                        ccode.add_expression (free_call);
@@ -3308,7 +3313,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                                if (type.type_symbol is Struct && ((Struct) type.type_symbol).is_disposable ()) {
                                                        unref_function = generate_free_func_wrapper (type);
                                                } else {
-                                                       unref_function = "g_free";
+                                                       if (context.profile == Profile.POSIX) {
+                                                               unref_function = "free";
+                                                       } else {
+                                                               unref_function = "g_free";
+                                                       }
                                                }
                                        }
                                } else if (type is EnumValueType) {