+2009-02-12 Jürg Billeter <j@bitron.ch>
+
+ * gobject/valaccodearraymodule.vala:
+
+ Keep arrays NULL-terminated when appending
+
2009-02-11 Ryan Lortie <desrt@desrt.ca>
Bug 571263 – make yielding functions dispatch results to mainloop
var renew_call = new CCodeFunctionCall (new CCodeIdentifier ("g_renew"));
renew_call.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ()));
renew_call.add_argument (array);
- renew_call.add_argument (size);
+ if (array_type.element_type.is_reference_type_or_type_parameter ()) {
+ // NULL terminate array
+ renew_call.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, size, new CCodeConstant ("1")));
+ } else {
+ renew_call.add_argument (size);
+ }
var resize_block = new CCodeBlock ();
resize_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (size, new CCodeConditionalExpression (size, new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeConstant ("2"), size), new CCodeConstant ("4")))));
block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeElementAccess (array, new CCodeUnaryExpression (CCodeUnaryOperator.POSTFIX_INCREMENT, length)), value)));
+ if (array_type.element_type.is_reference_type_or_type_parameter ()) {
+ // NULL terminate array
+ block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeElementAccess (array, length), new CCodeConstant ("NULL"))));
+ }
+
// append to file
source_type_member_declaration.append (function.copy ());