diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-18 20:10:48 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-18 20:10:48 +0100 |
commit | d6e24bd795d5d1d00c2414efe2e5d9e1152c5f5b (patch) | |
tree | 6b5b52814dffba45b6c3fd6e19bf50fab55b6798 /miscutils | |
parent | 30a8e0c2f9006db75840724ce89883595dfc7379 (diff) |
bc: simplify bc_array_expand()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/bc.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index e62ca0f69..7ddae341f 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -2547,17 +2547,19 @@ static void bc_array_init(BcVec *a, bool nums) static void bc_array_expand(BcVec *a, size_t len) { - BcResultData data; - - if (a->size == sizeof(BcNum) && a->dtor == bc_num_free) { + if (a->dtor == bc_num_free + // && a->size == sizeof(BcNum) - always true + ) { + BcNum n; while (len > a->len) { - bc_num_init_DEF_SIZE(&data.n); - bc_vec_push(a, &data.n); + bc_num_init_DEF_SIZE(&n); + bc_vec_push(a, &n); } } else { + BcVec v; while (len > a->len) { - bc_array_init(&data.v, true); - bc_vec_push(a, &data.v); + bc_array_init(&v, true); + bc_vec_push(a, &v); } } } |