MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / pl_named_sections

Function pl_named_sections

internal/cbm/doclink_perl.c:1057–1073  ·  view source on GitHub ↗

The sections that name something, sorted by name and then by position. */

Source from the content-addressed store, hash-verified

1055
1056/* The sections that name something, sorted by name and then by position. */
1057static 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`. */
1076static int pl_named_first(const pl_named_t *named, int count, const char *name) {

Callers 1

pl_harvest_fileFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected