From: Rico Tzschichholz Date: Sat, 19 Oct 2019 15:41:31 +0000 (+0200) Subject: codegen: Correctly transform arguments of Array.resize() for realloc (POSIX) X-Git-Tag: 0.47.1~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3ff8af3abb872ad5a98a0661097b266ede0f2c5;p=thirdparty%2Fvala.git codegen: Correctly transform arguments of Array.resize() for realloc (POSIX) --- diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index 1fa3aebb2..c5b36f86a 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -193,7 +193,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { // the complete call expression, might include casts, comma expressions, and/or assignments CCodeExpression ccall_expr = ccall; - if (m is ArrayResizeMethod) { + if (m is ArrayResizeMethod && context.profile != Profile.POSIX) { var array_type = (ArrayType) ma.inner.value_type; in_arg_map.set (get_param_pos (0), new CCodeIdentifier (get_ccode_name (array_type.element_type))); } else if (m is ArrayMoveMethod) { @@ -494,6 +494,13 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { arg_pos = get_param_pos (param != null ? get_ccode_pos (param) : i, ellipsis); carg_map.set (arg_pos, cexpr); + if (m is ArrayResizeMethod && context.profile == Profile.POSIX) { + var csizeof = new CCodeIdentifier ("sizeof (%s)".printf (get_ccode_name (((ArrayType) ma.inner.value_type).element_type))); + carg_map.set (arg_pos, new CCodeBinaryExpression (CCodeBinaryOperator.MUL, csizeof, cexpr)); + } else { + carg_map.set (arg_pos, cexpr); + } + if (arg is NamedArgument && ellipsis) { var named_arg = (NamedArgument) arg; string name = string.joinv ("-", named_arg.name.split ("_"));