summaryrefslogtreecommitdiffhomepage
path: root/miscutils
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index f936ad6f3..3d53db778 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -1069,8 +1069,12 @@ static void bc_vec_expand(BcVec *v, size_t req)
}
}
-#define bc_vec_pop(v) (bc_vec_npop((v), 1))
-#define bc_vec_top(v) (bc_vec_item_rev((v), 0))
+static void bc_vec_pop(BcVec *v)
+{
+ v->len--;
+ if (v->dtor)
+ v->dtor(v->v + (v->size * v->len));
+}
static void bc_vec_npop(BcVec *v, size_t n)
{
@@ -1094,8 +1098,6 @@ static void bc_vec_push(BcVec *v, const void *data)
v->len += 1;
}
-#define bc_parse_push(p, i) bc_vec_pushByte(&(p)->func->code, (char) (i))
-
static void bc_vec_pushByte(BcVec *v, char data)
{
bc_vec_push(v, &data);
@@ -1159,6 +1161,11 @@ static void *bc_vec_item_rev(const BcVec *v, size_t idx)
return v->v + v->size * (v->len - idx - 1);
}
+static void *bc_vec_top(const BcVec *v)
+{
+ return v->v + v->size * (v->len - 1);
+}
+
static void bc_vec_free(void *vec)
{
BcVec *v = (BcVec *) vec;
@@ -3530,6 +3537,8 @@ static void bc_parse_addFunc(BcParse *p, char *name, size_t *idx)
p->func = bc_vec_item(&G.prog.fns, p->fidx);
}
+#define bc_parse_push(p, i) bc_vec_pushByte(&(p)->func->code, (char) (i))
+
static void bc_parse_pushName(BcParse *p, char *name)
{
size_t i = 0, len = strlen(name);