don't NULL-terminate value-type arrays
authorJuerg Billeter <j@bitron.ch>
Thu, 30 Aug 2007 21:39:22 +0000 (21:39 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Thu, 30 Aug 2007 21:39:22 +0000 (21:39 +0000)
2007-08-30  Juerg Billeter  <j@bitron.ch>

* gobject/valacodegenerator.vala: don't NULL-terminate value-type arrays

svn path=/trunk/; revision=548

ChangeLog
gobject/valacodegenerator.vala

index f8f1b11..655f0d4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2007-08-30  Jürg Billeter  <j@bitron.ch>
 
+       * gobject/valacodegenerator.vala: don't NULL-terminate value-type arrays
+
+2007-08-30  Jürg Billeter  <j@bitron.ch>
+
        * vala/valamemberaccess.vala, vala/valasemanticanalyzer.vala: support
          prototype access to allow accessing instance members without an
          actual instance, fixes bug 471778
index 7949698..cc03c69 100644 (file)
@@ -1945,7 +1945,13 @@ public class Vala.CodeGenerator : CodeVisitor {
                bool first = true;
                CCodeExpression cexpr = null;
                foreach (Expression size in expr.get_sizes ()) {
-                       var csize = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, (CCodeExpression) size.ccodenode, new CCodeConstant ("1"));
+                       CCodeExpression csize;
+                       if (expr.element_type.data_type != null && expr.element_type.data_type.is_reference_type ()) {
+                               // add extra item to have array NULL-terminated for all reference types
+                               csize = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, (CCodeExpression) size.ccodenode, new CCodeConstant ("1"));
+                       } else {
+                               csize = (CCodeExpression) size.ccodenode;
+                       }
 
                        if (first) {
                                cexpr = csize;