ref: 20a26599a3de9fa7c24f8daef7310721b2c2958a
parent: 7bdfc9da23180937b014c13495aaaae62176fcdd
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Wed Dec 1 15:24:31 EST 2021
Simplify allocating multiple `ds` args Dealing with indexes is only necessary for `strfmt`
--- a/src/asm/parser.y
+++ b/src/asm/parser.y
@@ -385,7 +385,7 @@
strerror(errno));
}
-static size_t nextDsArgListIndex(struct DsArgList *args)
+static void appendDsArgList(struct DsArgList *args, const struct Expression *expr)
{
if (args->nbArgs == args->capacity) {
args->capacity = (args->capacity + 1) * 2;
@@ -394,7 +394,7 @@
fatalerror("realloc error while resizing ds arg list: %s\n",
strerror(errno));
}
- return args->nbArgs++;
+ args->args[args->nbArgs++] = *expr;
}
static void freeDsArgList(struct DsArgList *args)
@@ -1144,14 +1144,10 @@
ds_args : reloc_8bit {
initDsArgList(&$$);
- size_t i = nextDsArgListIndex(&$$);
-
- $$.args[i] = $1;
+ appendDsArgList(&$$, &$1);
}
| ds_args T_COMMA reloc_8bit {
- size_t i = nextDsArgListIndex(&$1);
-
- $1.args[i] = $3;
+ appendDsArgList(&$1, &$3);
$$ = $1;
}
;