[vala/staging] codegen: Use alternative for g_free in POSIX profile
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Use alternative for g_free in POSIX profile
- Date: Sat, 19 Oct 2019 08:39:04 +0000 (UTC)
commit f14177023fb2d6faf75a74371a8dba083d4d9645
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Oct 19 00:12:26 2019 +0200
codegen: Use alternative for g_free in POSIX profile
codegen/valaccodearraymodule.vala | 14 ++++++++++++--
codegen/valaccodebasemodule.vala | 13 +++++++++++--
2 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index e609a1031..e71f41d70 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -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);
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index ddce144e1..d3f4f416d 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]