From 0e05d09b309bab493c41b6c788933cf82587afb8 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sat, 31 Oct 2026 13:54:24 +0100 Subject: td.c: Use triplet for pointer type --- src/prc1/type.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/prc1/type.c') diff --git a/src/prc1/type.c b/src/prc1/type.c index fbb332b..2b10da0 100644 --- a/src/prc1/type.c +++ b/src/prc1/type.c @@ -307,9 +307,13 @@ static int anum(const struct lex *l, struct prv *p) static int p(const struct lex *l, struct prv *p) { - struct type *t = malloc(sizeof *t), *tt; + const char *tr = triplet(p); + const struct type *ptr; + struct type *t, *tt; - if (!t) + if (!tr || !(ptr = triplet_ptr(tr))) + return -1; + else if (!(t = malloc(sizeof *t))) { perror("malloc(3)"); return -1; @@ -319,8 +323,8 @@ static int p(const struct lex *l, struct prv *p) { .type = PTR, /* TODO: ask target for sizeof (void *) */ - .sz = sizeof (void *), - .align = sizeof (void *) + .sz = ptr->sz, + .align = ptr->align }; if ((tt = p->t) && tt->type == ARY) -- cgit v1.2.3