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

Function adr_try_section_header

src/store/store.c:11015–11035  ·  view source on GitHub ↗

Try to extract a canonical section header from a "## Header" line. * Returns heap-allocated header string if canonical, NULL otherwise. */

Source from the content-addressed store, hash-verified

11013/* Try to extract a canonical section header from a "## Header" line.
11014 * Returns heap-allocated header string if canonical, NULL otherwise. */
11015static char *adr_try_section_header(const char *line, int line_len) {
11016 if (line_len <= ST_HEADER_PREFIX || line[0] != '#' || line[SKIP_ONE] != '#' ||
11017 line[PAIR_LEN] != ' ') {
11018 return NULL;
11019 }
11020 char header[CBM_SZ_64];
11021 int hlen = line_len - ST_HEADER_PREFIX;
11022 if (hlen >= (int)sizeof(header)) {
11023 hlen = (int)sizeof(header) - SKIP_ONE;
11024 }
11025 memcpy(header, line + 3, hlen);
11026 header[hlen] = '\0';
11027 while (hlen > 0 && (header[hlen - SKIP_ONE] == ' ' || header[hlen - SKIP_ONE] == '\t' ||
11028 header[hlen - SKIP_ONE] == '\r')) {
11029 header[--hlen] = '\0';
11030 }
11031 if (!is_canonical_section(header)) {
11032 return NULL;
11033 }
11034 return heap_strdup(header);
11035}
11036
11037/* Append a line to the current section content buffer. */
11038static void adr_append_line(char *buf, int buf_sz, int *len, const char *line, int line_len) {

Callers 1

cbm_adr_parse_sectionsFunction · 0.85

Calls 2

is_canonical_sectionFunction · 0.85
heap_strdupFunction · 0.70

Tested by

no test coverage detected