vala r2431 - in trunk: . gobject
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2431 - in trunk: . gobject
- Date: Thu, 12 Feb 2009 11:39:03 +0000 (UTC)
Author: juergbi
Date: Thu Feb 12 11:39:03 2009
New Revision: 2431
URL: http://svn.gnome.org/viewvc/vala?rev=2431&view=rev
Log:
2009-02-12 JÃrg Billeter <j bitron ch>
* gobject/valaccodearraymodule.vala:
Keep arrays NULL-terminated when appending
Modified:
trunk/ChangeLog
trunk/gobject/valaccodearraymodule.vala
Modified: trunk/gobject/valaccodearraymodule.vala
==============================================================================
--- trunk/gobject/valaccodearraymodule.vala (original)
+++ trunk/gobject/valaccodearraymodule.vala Thu Feb 12 11:39:03 2009
@@ -601,7 +601,12 @@
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")))));
@@ -612,6 +617,11 @@
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 ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]