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

Function cbm_adr_parse_sections

src/store/store.c:11049–11081  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11047}
11048
11049cbm_adr_sections_t cbm_adr_parse_sections(const char *content) {
11050 cbm_adr_sections_t result;
11051 memset(&result, 0, sizeof(result));
11052 if (!content || !content[0]) {
11053 return result;
11054 }
11055
11056 const char *p = content;
11057 char *current_section = NULL;
11058 char current_content[ST_SQL_BUF] = "";
11059 int content_len = 0;
11060
11061 while (*p) {
11062 const char *eol = strchr(p, '\n');
11063 int line_len = eol ? (int)(eol - p) : (int)strlen(p);
11064
11065 char *new_section = adr_try_section_header(p, line_len);
11066 if (new_section) {
11067 adr_save_section(&result, current_section, current_content, content_len);
11068 current_section = new_section;
11069 current_content[0] = '\0';
11070 content_len = 0;
11071 } else if (current_section && (content_len > 0 || line_len > 0)) {
11072 adr_append_line(current_content, (int)sizeof(current_content), &content_len, p,
11073 line_len);
11074 }
11075
11076 p = eol ? eol + SKIP_ONE : p + line_len;
11077 }
11078
11079 adr_save_section(&result, current_section, current_content, content_len);
11080 return result;
11081}
11082
11083/* Append a section to the render buffer.
11084 *

Callers 2

cbm_adr_validate_contentFunction · 0.85
test_store_arch.cFile · 0.85

Calls 3

adr_try_section_headerFunction · 0.85
adr_save_sectionFunction · 0.85
adr_append_lineFunction · 0.85

Tested by

no test coverage detected