cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 4ea975dc7ac54d33492a88b9cc15dd717023800e
parent 84da43b2235b1ec82b84ef8100c05097bc3ca4f5
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 18 Mar 2020 15:18:03 -0700

pp: Remove some unnecessary conditionals

It is fine to just pass NULL, or the result of malloc(0) to free().

Diffstat:
Mpp.c | 12+++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/pp.c b/pp.c @@ -424,11 +424,7 @@ expand(struct token *t) paren = 0; depth = macrodepth; tok = (struct array){0}; - if (m->nparam > 0) { - arg = xreallocarray(NULL, m->nparam, sizeof(*arg)); - } else { - arg = NULL; - } + arg = xreallocarray(NULL, m->nparam, sizeof(*arg)); t = rawnext(); for (i = 0; i < m->nparam; ++i) { if (m->param[i].flags & PARAMSTR) { @@ -473,10 +469,8 @@ expand(struct token *t) if (t->kind != TRPAREN) error(&t->loc, "too many arguments for macro '%s'", m->name); for (i = 0, t = tok.val; i < m->nparam; ++i) { - if (m->param[i].flags & PARAMTOK) { - arg[i].token = t; - t += arg[i].ntoken; - } + arg[i].token = t; + t += arg[i].ntoken; } m->arg = arg; }