Merge pull request #80 from jeberger/master

Fix for bugs #78 and #79
This commit is contained in:
Daniel Holden
2018-03-20 08:04:03 -07:00
committed by GitHub

6
mpc.c
View File

@@ -3644,7 +3644,7 @@ static int mpc_nodecount_unretained(mpc_parser_t* p, int force) {
if (p->type == MPC_TYPE_COUNT) { return 1 + mpc_nodecount_unretained(p->data.repeat.x, 0); }
if (p->type == MPC_TYPE_OR) {
total = 0;
total = 1;
for(i = 0; i < p->data.or.n; i++) {
total += mpc_nodecount_unretained(p->data.or.xs[i], 0);
}
@@ -3652,7 +3652,7 @@ static int mpc_nodecount_unretained(mpc_parser_t* p, int force) {
}
if (p->type == MPC_TYPE_AND) {
total = 0;
total = 1;
for(i = 0; i < p->data.and.n; i++) {
total += mpc_nodecount_unretained(p->data.and.xs[i], 0);
}
@@ -3725,7 +3725,7 @@ static void mpc_optimise_unretained(mpc_parser_t *p, int force) {
n = p->data.or.n; m = t->data.or.n;
p->data.or.n = n + m - 1;
p->data.or.xs = realloc(p->data.or.xs, sizeof(mpc_parser_t*) * (n + m -1));
memmove(p->data.or.xs + m, t->data.or.xs + 1, n * sizeof(mpc_parser_t*));
memmove(p->data.or.xs + m, p->data.or.xs + 1, (n - 1) * sizeof(mpc_parser_t*));
memmove(p->data.or.xs, t->data.or.xs, m * sizeof(mpc_parser_t*));
free(t->data.or.xs); free(t->name); free(t);
continue;