aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2020-03-18 15:18:03 -0700
committerMichael Forney <mforney@mforney.org>2020-03-18 15:50:33 -0700
commit4ea975dc7ac54d33492a88b9cc15dd717023800e (patch)
treeae34dc9126ded403c6371df3f726eca5a17f45bc
parent84da43b2235b1ec82b84ef8100c05097bc3ca4f5 (diff)
pp: Remove some unnecessary conditionals
It is fine to just pass NULL, or the result of malloc(0) to free().
-rw-r--r--pp.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/pp.c b/pp.c
index cff625b..8086d2a 100644
--- 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;
}