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

Function adr_try_section_header

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

5685/* Try to extract a canonical section header from a "## Header" line.
5686 * Returns heap-allocated header string if canonical, NULL otherwise. */
5687static char *adr_try_section_header(const char *line, int line_len) {
5688 if (line_len <= ST_HEADER_PREFIX || line[0] != '#' || line[SKIP_ONE] != '#' ||
5689 line[PAIR_LEN] != ' ') {
5690 return NULL;
5691 }
5692 char header[CBM_SZ_64];
5693 int hlen = line_len - ST_HEADER_PREFIX;
5694 if (hlen >= (int)sizeof(header)) {
5695 hlen = (int)sizeof(header) - SKIP_ONE;
5696 }
5697 memcpy(header, line + 3, hlen);
5698 header[hlen] = '\0';
5699 while (hlen > 0 && (header[hlen - SKIP_ONE] == ' ' || header[hlen - SKIP_ONE] == '\t' ||
5700 header[hlen - SKIP_ONE] == '\r')) {
5701 header[--hlen] = '\0';
5702 }
5703 if (!is_canonical_section(header)) {
5704 return NULL;
5705 }
5706 return heap_strdup(header);
5707}
5708
5709/* Append a line to the current section content buffer. */
5710static 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