| 4599 | }; |
| 4600 | |
| 4601 | static bool cmm_hook_args_equal(yyjson_mut_val *hook, const char *const *expected_args, |
| 4602 | size_t expected_arg_count) { |
| 4603 | yyjson_mut_val *args = yyjson_mut_is_obj(hook) ? yyjson_mut_obj_get(hook, "args") : NULL; |
| 4604 | if (expected_arg_count == 0U) { |
| 4605 | return args == NULL; |
| 4606 | } |
| 4607 | if (!expected_args || !args || !yyjson_mut_is_arr(args) || |
| 4608 | yyjson_mut_arr_size(args) != expected_arg_count) { |
| 4609 | return false; |
| 4610 | } |
| 4611 | for (size_t i = 0U; i < expected_arg_count; i++) { |
| 4612 | yyjson_mut_val *arg = yyjson_mut_arr_get(args, i); |
| 4613 | if (!expected_args[i] || !arg || !yyjson_mut_is_str(arg) || |
| 4614 | strcmp(yyjson_mut_get_str(arg), expected_args[i]) != 0) { |
| 4615 | return false; |
| 4616 | } |
| 4617 | } |
| 4618 | return true; |
| 4619 | } |
| 4620 | |
| 4621 | /* Check if a hook array entry is ours (current matcher or a known old one). |
| 4622 | * Matcher identity is never sufficient because users commonly choose the same |
no outgoing calls
no test coverage detected