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

Function adr_try_section_header

src/store/store.c:7826–7846  ·  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

7824/* Try to extract a canonical section header from a "## Header" line.
7825 * Returns heap-allocated header string if canonical, NULL otherwise. */
7826static char *adr_try_section_header(const char *line, int line_len) {
7827 if (line_len <= ST_HEADER_PREFIX || line[0] != '#' || line[SKIP_ONE] != '#' ||
7828 line[PAIR_LEN] != ' ') {
7829 return NULL;
7830 }
7831 char header[CBM_SZ_64];
7832 int hlen = line_len - ST_HEADER_PREFIX;
7833 if (hlen >= (int)sizeof(header)) {
7834 hlen = (int)sizeof(header) - SKIP_ONE;
7835 }
7836 memcpy(header, line + 3, hlen);
7837 header[hlen] = '\0';
7838 while (hlen > 0 && (header[hlen - SKIP_ONE] == ' ' || header[hlen - SKIP_ONE] == '\t' ||
7839 header[hlen - SKIP_ONE] == '\r')) {
7840 header[--hlen] = '\0';
7841 }
7842 if (!is_canonical_section(header)) {
7843 return NULL;
7844 }
7845 return heap_strdup(header);
7846}
7847
7848/* Append a line to the current section content buffer. */
7849static 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