aboutsummaryrefslogtreecommitdiff
path: root/src/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-10-05 17:52:33 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-10-05 17:52:33 -0400
commit398d2cab6988e20c59e7037ff7ef551540339abb (patch)
tree8c5154cfcd32d0664fd40ac8fa93f50f6434859a /src/types.c
parent9b5b6b110bb80f8530dd7ca4e0cc9eb3236d8ad7 (diff)
Fix a bunch of issues with optional types
Diffstat (limited to 'src/types.c')
-rw-r--r--src/types.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/types.c b/src/types.c
index 900588f5..bf986c80 100644
--- a/src/types.c
+++ b/src/types.c
@@ -476,11 +476,9 @@ PUREFUNC size_t type_size(type_t *t) {
default: errx(1, "Invalid integer bit size");
}
case StructType: {
- size_t size = unpadded_struct_size(nonnull);
- size += sizeof(bool); // is_null flag
- size_t align = type_align(nonnull);
- if (align > 0 && (size % align) > 0) size = (size + align) - (size % align);
- return size;
+ arg_t *fields = new (arg_t, .name = "value", .type = nonnull,
+ .next = new (arg_t, .name = "has_value", .type = Type(BoolType)));
+ return type_size(Type(StructType, .fields = fields));
}
default: return type_size(nonnull);
}