Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "array.h" | ||
2 | #include "str-util.h" | ||
3 | #include "xmalloc.h" | ||
4 | |||
5 | // This can be used to collect all prefix-matched strings from a "flat" array | ||
6 | // (i.e. an array of fixed-length char arrays; *not* pointers to char) | ||
7 | 19 | void collect_strings_from_flat_array ( | |
8 | const char *base, | ||
9 | size_t nr_elements, | ||
10 | size_t element_len, | ||
11 | PointerArray *a, | ||
12 | const char *prefix | ||
13 | ) { | ||
14 | 19 | const char *end = base + (nr_elements * element_len); | |
15 |
2/2✓ Branch 0 taken 787 times.
✓ Branch 1 taken 19 times.
|
806 | for (const char *str = base; str < end; str += element_len) { |
16 |
2/2✓ Branch 0 taken 309 times.
✓ Branch 1 taken 478 times.
|
787 | if (str_has_prefix(str, prefix)) { |
17 | 309 | ptr_array_append(a, xstrdup(str)); | |
18 | } | ||
19 | } | ||
20 | 19 | } | |
21 |