From: Luca Bruno Date: Sun, 25 Dec 2011 12:43:28 +0000 (+0100) Subject: codegen: Use NULL as default C value for nullable structs X-Git-Tag: 0.14.2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77aaaf1a57e4a9076d7c9584283d6987553854eb;p=thirdparty%2Fvala.git codegen: Use NULL as default C value for nullable structs Fixes bug 665904. --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index f5ca0c0bb..8df596643 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -5448,7 +5448,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { public CCodeExpression? default_value_for_type (DataType type, bool initializer_expression) { var st = type.data_type as Struct; var array_type = type as ArrayType; - if (type.data_type != null && get_ccode_default_value (type.data_type) != "") { + if (type.data_type != null && !type.nullable && get_ccode_default_value (type.data_type) != "") { return new CCodeConstant (get_ccode_default_value (type.data_type)); } else if (initializer_expression && !type.nullable && (st != null || (array_type != null && array_type.fixed_length))) {