The sections that name something, sorted by name and then by position. */
| 1055 | |
| 1056 | /* The sections that name something, sorted by name and then by position. */ |
| 1057 | static pl_named_t *pl_named_sections(const pl_scan_t *s, int *count) { |
| 1058 | *count = 0; |
| 1059 | pl_named_t *named = |
| 1060 | (pl_named_t *)cbm_arena_alloc(s->a, (size_t)(s->nsecs + SKIP_ONE) * sizeof(*named)); |
| 1061 | if (!named) { |
| 1062 | return NULL; |
| 1063 | } |
| 1064 | int n = 0; |
| 1065 | for (int i = 0; i < s->nsecs; i++) { |
| 1066 | if (s->secs[i].name_len > 0) { |
| 1067 | named[n++] = (pl_named_t){s->secs[i].name, s->secs[i].name_len, i}; |
| 1068 | } |
| 1069 | } |
| 1070 | qsort(named, (size_t)n, sizeof(*named), pl_named_cmp); |
| 1071 | *count = n; |
| 1072 | return named; |
| 1073 | } |
| 1074 | |
| 1075 | /* Index of the first section named `name`, or `count`. */ |
| 1076 | static int pl_named_first(const pl_named_t *named, int count, const char *name) { |
no test coverage detected