diff --git a/src/matcher.c b/src/matcher.c index 4e7ed3b..bfa7a87 100644 --- a/src/matcher.c +++ b/src/matcher.c @@ -24,6 +24,8 @@ apfl_matcher_new(struct gc *gc, struct matcher_instruction_list *milist) { struct matcher matcher = { .instructions = milist, + .value_count = 0, + .capture_count = 0, .values = NULL, .captures = NULL, .result = false, @@ -32,10 +34,12 @@ apfl_matcher_new(struct gc *gc, struct matcher_instruction_list *milist) if (!init_values_list(gc->allocator, &matcher.values, milist->value_count)) { goto error; } + matcher.value_count = milist->value_count; if (!init_values_list(gc->allocator, &matcher.captures, milist->capture_count)) { goto error; } + matcher.capture_count = milist->capture_count; struct matcher *gc_matcher = apfl_gc_new_matcher(gc); if (gc_matcher == NULL) { @@ -54,8 +58,8 @@ error: void apfl_matcher_deinit(struct apfl_allocator allocator, struct matcher *matcher) { - FREE_LIST(allocator, matcher->values, matcher->instructions->value_count); - FREE_LIST(allocator, matcher->captures, matcher->instructions->capture_count); + FREE_LIST(allocator, matcher->values, matcher->value_count); + FREE_LIST(allocator, matcher->captures, matcher->capture_count); } void diff --git a/src/matcher.h b/src/matcher.h index fbe5cfa..36dbb93 100644 --- a/src/matcher.h +++ b/src/matcher.h @@ -11,6 +11,8 @@ extern "C" { struct matcher { struct matcher_instruction_list *instructions; + size_t value_count; + size_t capture_count; struct apfl_value *values; struct apfl_value *captures; bool result;