CCodeFunctionCall carrfree;
if (context.profile == Profile.POSIX) {
+ cfile.add_include ("stdlib.h");
carrfree = new CCodeFunctionCall (new CCodeIdentifier ("free"));
} else {
carrfree = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
public override void append_vala_array_free () {
// _vala_array_destroy only frees elements but not the array itself
+ generate_type_declaration (delegate_target_destroy_type, cfile);
var fun = new CCodeFunction ("_vala_array_destroy", "void");
fun.modifiers = CCodeModifiers.STATIC;
CCodeFunctionCall carrfree;
if (context.profile == Profile.POSIX) {
+ cfile.add_include ("stdlib.h");
carrfree = new CCodeFunctionCall (new CCodeIdentifier ("free"));
} else {
carrfree = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
}
requires_array_free = true;
+ generate_type_declaration (delegate_target_destroy_type, cfile);
var ccall = new CCodeFunctionCall (get_destroy_func_expression (type));
if (context.profile == Profile.POSIX) {
cfile.add_include ("stdlib.h");
+ cfile.add_include ("string.h");
+
var alloc = new CCodeFunctionCall (new CCodeIdentifier ("calloc"));
alloc.add_argument (length_expr);
alloc.add_argument (sizeof_call);
CCodeFunctionCall free_call;
if (context.profile == Profile.POSIX) {
+ cfile.add_include ("stdlib.h");
free_call = new CCodeFunctionCall (new CCodeIdentifier ("free"));
} else {
free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
unref_function = generate_free_func_wrapper (type);
} else {
if (context.profile == Profile.POSIX) {
+ cfile.add_include ("stdlib.h");
unref_function = "free";
} else {
unref_function = "g_free";
}
} else if (type is ArrayType) {
if (context.profile == Profile.POSIX) {
+ cfile.add_include ("stdlib.h");
return new CCodeIdentifier ("free");
} else {
return new CCodeIdentifier ("g_free");
}
} else if (type is PointerType) {
if (context.profile == Profile.POSIX) {
+ cfile.add_include ("stdlib.h");
return new CCodeIdentifier ("free");
} else {
return new CCodeIdentifier ("g_free");
ccall.add_argument (csizeexpr);
} else {
requires_array_free = true;
+ generate_type_declaration (delegate_target_destroy_type, cfile);
+
ccall.call = new CCodeIdentifier ("_vala_array_free");
ccall.add_argument (csizeexpr);
ccall.add_argument (new CCodeCastExpression (get_destroy_func_expression (array_type.element_type), get_ccode_name (delegate_target_destroy_type)));
ccode.add_expression (va_start);
+ if (context.profile == Profile.POSIX) {
+ cfile.add_include ("stdio.h");
+ }
+
var vsnprintf = new CCodeFunctionCall (new CCodeIdentifier ("vsnprintf"));
vsnprintf.add_argument (new CCodeConstant ("NULL"));
vsnprintf.add_argument (new CCodeConstant ("0"));