Simplify loading code

Turns out past me allowed a subfunction to not have a matcher at all,
in which case everything is matched. This is exactly what we want to
happen for a apfl_load()ed function, so we don't needt to construct a
matcher here at all and can keep things a bit simpler. Nice :)
This commit is contained in:
Laria 2025-11-20 21:31:08 +01:00
parent 7a26a7793b
commit 8d1f1e4ada

View file

@ -2358,38 +2358,8 @@ setup_function_for_load_inner(apfl_ctx ctx, struct apfl_string *filename)
return NULL;
}
struct matcher_instruction_list *milist = apfl_matcher_instructions_new(&ctx->gc);
if (
milist == NULL
|| !apfl_gc_tmproot_add(&ctx->gc, GC_OBJECT_FROM(milist, GC_TYPE_MATCHER_INSTRUCTIONS))
) {
return NULL;
}
if (!apfl_resizable_append(
ctx->gc.allocator,
sizeof(union matcher_instruction_or_arg),
(void **)&milist->instructions,
&milist->len,
&milist->cap,
&(union matcher_instruction_or_arg[]) {
{.instruction = MATCHER_IGNORE},
},
1
)) {
return NULL;
}
struct matcher *matcher = apfl_matcher_new(&ctx->gc, milist);
if (
matcher == NULL
|| !apfl_gc_tmproot_add(&ctx->gc, GC_OBJECT_FROM(matcher, GC_TYPE_MATCHER))
) {
apfl_drop(ctx, -1);
return NULL;
}
if (!apfl_func_add_subfunc(func_value->func, ilist, matcher)) {
if (!apfl_func_add_subfunc(func_value->func, ilist, NULL)) {
apfl_drop(ctx, -1);
return NULL;
}