summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rt_struct.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/rt_struct.c b/rt_struct.c
index 314407c..34556ca 100644
--- a/rt_struct.c
+++ b/rt_struct.c
@@ -7,6 +7,10 @@ static int is_root_type(rts_type_tag tag) {
return tag != TAG_STRUCT && tag != TAG_UNION;
}
+static int member_is_ptr(rts_member_type type) {
+ return type >= MBR_PTR && type <= MBR_PTR_ARRAY_NULL;
+}
+
int create_rts(rts_type *type) {
if (type == NULL) {
return 1;
@@ -24,11 +28,12 @@ int create_rts(rts_type *type) {
size_t remainder = 0;
size_t padding = 0;
rts_member **members = type->members;
+
for (int i = 0; members[i] != NULL; ++i) {
- rts_type *member_type = members[i]->type;
- if (create_rts(member_type)) {
+ if (create_rts(members[i]->type)) {
return 1;
} else {
+ const rts_type *member_type = (member_is_ptr(members[i]->mbr_type)) ? &RTS_TYPE_POINTER : members[i]->type;
const size_t align = member_type->alignment;
max_align = max(max_align, align);
if (type->tag == TAG_STRUCT) {