19 const int32_t *group_counts,
size_t group_count_elements,
20 size_t groups,
size_t rows,
21 int32_t *row_indices,
size_t row_index_elements,
22 int32_t *owner_indices,
size_t owner_index_elements) {
23 if (!groups || !rows || groups > INT32_MAX || rows > INT32_MAX ||
24 group_count_elements < groups || row_index_elements < rows ||
25 owner_index_elements < rows)
27 if (!
region_ok(group_counts, group_count_elements,
sizeof(int32_t)) ||
28 !
region_ok(row_indices, row_index_elements,
sizeof(int32_t)) ||
29 !
region_ok(owner_indices, owner_index_elements,
sizeof(int32_t)))
31 if (
overlaps(group_counts, group_count_elements *
sizeof(int32_t),
32 row_indices, row_index_elements *
sizeof(int32_t)) ||
33 overlaps(group_counts, group_count_elements *
sizeof(int32_t),
34 owner_indices, owner_index_elements *
sizeof(int32_t)) ||
35 overlaps(row_indices, row_index_elements *
sizeof(int32_t),
36 owner_indices, owner_index_elements *
sizeof(int32_t)))
39 for (
size_t group = 0; group < groups; ++group) {
40 int32_t
count = group_counts[group];
41 if (
count <= 0 || (
size_t)
count > rows - total)
return -2;
42 total += (size_t)
count;
44 if (total != rows)
return -2;
46 for (
size_t group = 0; group < groups; ++group) {
47 for (int32_t item = 0; item < group_counts[group]; ++item, ++row) {
48 row_indices[row] = (int32_t)row;
49 owner_indices[row] = (int32_t)group;
int ck_expand_group_row_indices_checked_i32(const int32_t *group_counts, size_t group_count_elements, size_t groups, size_t rows, int32_t *row_indices, size_t row_index_elements, int32_t *owner_indices, size_t owner_index_elements)