dte test coverage


Directory: ./
File: src/util/array.c
Date: 2025-05-08 15:05:54
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 1 1 100.0%
Branches: 4 4 100.0%

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 17 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 17 const char *end = base + (nr_elements * element_len);
15 17 size_t prefix_len = strlen(prefix);
16
2/2
✓ Branch 0 (7→3) taken 551 times.
✓ Branch 1 (7→8) taken 17 times.
568 for (const char *str = base; str < end; str += element_len) {
17
2/2
✓ Branch 0 (3→4) taken 307 times.
✓ Branch 1 (3→6) taken 244 times.
551 if (str_has_strn_prefix(str, prefix, prefix_len)) {
18 307 ptr_array_append(a, xstrdup(str));
19 }
20 }
21 17 }
22