aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-03 15:06:59 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-03 15:06:59 -0400
commit16c2e3f590d5136e90a4d195a877502faa544715 (patch)
treecc07e362b4f64e85e510b1fd281d038371a6feba /types.c
parent52544344f10f0383d54795099c6b3a4f627c579a (diff)
Incrementally moving towards passing array entry sizes explicitly
Diffstat (limited to 'types.c')
-rw-r--r--types.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/types.c b/types.c
index 20049583..bb9268aa 100644
--- a/types.c
+++ b/types.c
@@ -486,6 +486,15 @@ size_t type_align(type_t *t)
errx(1, "This should not be reachable");
}
+size_t padded_type_size(type_t *t)
+{
+ size_t size = type_size(t);
+ size_t align = type_align(t);
+ if (align > 1 && size % align > 0)
+ size += align - (size % align); // Padding
+ return size;
+}
+
type_t *get_field_type(type_t *t, const char *field_name)
{
t = value_type(t);