Public arrays retain original spellings. Expanded patterns are separate, * so receipt/reporting clients do not lose the project configuration. */
| 489 | /* Public arrays retain original spellings. Expanded patterns are separate, |
| 490 | * so receipt/reporting clients do not lose the project configuration. */ |
| 491 | static bool tp_string_array(cbm_test_policy_t *policy, yyjson_val *value, bool nonempty, |
| 492 | const char *const **result, int *count, tp_patterns_t *patterns, |
| 493 | bool semantic_perf) { |
| 494 | if (!yyjson_is_arr(value)) |
| 495 | return false; |
| 496 | size_t size = yyjson_arr_size(value); |
| 497 | if ((nonempty && !size) || size > INT_MAX || size > SIZE_MAX / sizeof(char *)) |
| 498 | return false; |
| 499 | const char **items = size ? cbm_arena_alloc(&policy->arena, size * sizeof(*items)) : NULL; |
| 500 | if (size && !items) |
| 501 | return false; |
| 502 | size_t index, maximum; |
| 503 | yyjson_val *item; |
| 504 | yyjson_arr_foreach(value, index, maximum, item) { |
| 505 | size_t len = 0; |
| 506 | const char *text = tp_string(item, &len); |
| 507 | if (!text) |
| 508 | return false; |
| 509 | items[index] = cbm_arena_strndup(&policy->arena, text, len); |
| 510 | if (!items[index] || |
| 511 | (patterns && !tp_expand_pattern(policy, patterns, text, len, semantic_perf))) |
| 512 | return false; |
| 513 | } |
| 514 | *result = items; |
| 515 | *count = (int)size; |
| 516 | return true; |
| 517 | } |
| 518 | |
| 519 | static bool tp_parse_lanes(cbm_test_policy_t *policy, yyjson_val *value) { |
| 520 | if (!yyjson_is_arr(value) || !yyjson_arr_size(value) || yyjson_arr_size(value) > INT_MAX) |
no test coverage detected