aboutsummaryrefslogtreecommitdiffhomepage
path: root/type.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-05-26 09:20:58 +0200
committerlemon <lsof@mailbox.org>2023-05-26 09:20:58 +0200
commit640a3dac2b18d037169af15dfd5502c386c7e828 (patch)
tree79e7ee3fa81e73855ce1bc78d7c4bf1ad3ac8f0d /type.c
parent9100ed2b5dd01df8e6b766c7bc2a12c0dd44f1ff (diff)
hm
Diffstat (limited to 'type.c')
-rw-r--r--type.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/type.c b/type.c
index c973906..3aeb8a1 100644
--- a/type.c
+++ b/type.c
@@ -139,7 +139,9 @@ typesize(union type t)
case TYENUM:
return targ_primsizes[t.backing];
case TYARRAY:
- return t.flag & TFCHLDPRIM ? targ_primsizes[t.child] * t.arrlen : typedata[t.dat].siz;
+ if (t.flag & TFCHLDPRIM)
+ return targ_primsizes[t.child] * t.arrlen;
+ /* fallthru */
case TYSTRUCT:
case TYUNION:
return typedata[t.dat].siz;
@@ -180,7 +182,7 @@ mkarrtype(union type t, int qual, uint n)
if (isprim(t) && n < 256)
return mktype(TYARRAY, .flag = TFCHLDPRIM | (qual & TFCHLDQUAL), .child = t.t, .arrlen = n);
return mktype(TYARRAY, .flag = qual & TFCHLDQUAL,
- .dat = interntd(&(struct typedata) { TYARRAY, .child = t, .arrlen = n }));
+ .dat = interntd(&(struct typedata) { TYARRAY, .child = t, .arrlen = n, .siz = n * typesize(t) }));
}
union type