generate_struct_declaration (st, internal_header_file);
}
- if (context.profile == Profile.GOBJECT && !st.is_boolean_type () && !st.is_integer_type () && !st.is_floating_type ()) {
+ if (!st.is_boolean_type () && !st.is_integer_type () && !st.is_floating_type ()) {
if (st.is_disposable ()) {
begin_struct_destroy_function (st);
}
st.accept_children (this);
- if (context.profile == Profile.GOBJECT && !st.is_boolean_type () && !st.is_integer_type () && !st.is_floating_type ()) {
+ if (!st.is_boolean_type () && !st.is_integer_type () && !st.is_floating_type ()) {
if (st.is_disposable ()) {
add_struct_copy_function (st);
add_struct_destroy_function (st);
ccode.add_declaration (get_ccode_name (st) + "*", new CCodeVariableDeclarator ("dup"));
- var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
- creation_call.add_argument (new CCodeConstant (get_ccode_name (st)));
- creation_call.add_argument (new CCodeConstant ("1"));
- ccode.add_assignment (new CCodeIdentifier ("dup"), creation_call);
+ if (context.profile == Profile.GOBJECT) {
+ var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
+ creation_call.add_argument (new CCodeConstant (get_ccode_name (st)));
+ creation_call.add_argument (new CCodeConstant ("1"));
+ ccode.add_assignment (new CCodeIdentifier ("dup"), creation_call);
+ } else if (context.profile == Profile.POSIX) {
+ var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("calloc"));
+ creation_call.add_argument (new CCodeConstant ("1"));
+ creation_call.add_argument (new CCodeIdentifier ("sizeof (%s*)".printf (get_ccode_name (st))));
+ ccode.add_assignment (new CCodeIdentifier ("dup"), creation_call);
+ }
if (st.is_disposable ()) {
var copy_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_copy_function (st)));
ccode.add_expression (destroy_call);
}
- var free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
- free_call.add_argument (new CCodeIdentifier ("self"));
- ccode.add_expression (free_call);
+ if (context.profile == Profile.GOBJECT) {
+ var free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
+ free_call.add_argument (new CCodeIdentifier ("self"));
+ ccode.add_expression (free_call);
+ } else if (context.profile == Profile.POSIX) {
+ var free_call = new CCodeFunctionCall (new CCodeIdentifier ("free"));
+ free_call.add_argument (new CCodeIdentifier ("self"));
+ ccode.add_expression (free_call);
+ }
pop_function ();