summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko2018-12-19 20:05:50 +0100
committerDenys Vlasenko2018-12-19 20:05:50 +0100
commiteaa3b00002e23e2ecccade3e06790dd524e7b662 (patch)
tree9cc10f93ae359246d072f43a10476cabebdfe6e1 /miscutils
parent408b7d45f638dd163fc38d12d08ef94403412c90 (diff)
downloadbusybox-eaa3b00002e23e2ecccade3e06790dd524e7b662.zip
busybox-eaa3b00002e23e2ecccade3e06790dd524e7b662.tar.gz
bc: shorten bc_program_addFunc()
function old new delta bc_func_init - 50 +50 bc_program_addFunc 201 138 -63 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 50/-63) Total: -13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 7fcf00a..c59d5a2 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -3624,13 +3624,11 @@ static size_t bc_program_addFunc(char *name)
idx = entry_ptr->idx;
if (!inserted) {
+ // There is already a function with this name.
+ // It'll be redefined now, clear old definition.
BcFunc *func = bc_program_func(entry_ptr->idx);
-
- // We need to reset these, so the function can be repopulated.
- func->nparams = 0;
- bc_vec_pop_all(&func->autos);
- bc_vec_pop_all(&func->code);
- bc_vec_pop_all(&func->labels);
+ bc_func_free(func);
+ bc_func_init(func);
} else {
bc_func_init(&f);
bc_vec_push(&G.prog.fns, &f);