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

Function cbm_adr_parse_sections

src/store/store.c:7666–7698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7664}
7665
7666cbm_adr_sections_t cbm_adr_parse_sections(const char *content) {
7667 cbm_adr_sections_t result;
7668 memset(&result, 0, sizeof(result));
7669 if (!content || !content[0]) {
7670 return result;
7671 }
7672
7673 const char *p = content;
7674 char *current_section = NULL;
7675 char current_content[ST_SQL_BUF] = "";
7676 int content_len = 0;
7677
7678 while (*p) {
7679 const char *eol = strchr(p, '\n');
7680 int line_len = eol ? (int)(eol - p) : (int)strlen(p);
7681
7682 char *new_section = adr_try_section_header(p, line_len);
7683 if (new_section) {
7684 adr_save_section(&result, current_section, current_content, content_len);
7685 current_section = new_section;
7686 current_content[0] = '\0';
7687 content_len = 0;
7688 } else if (current_section && (content_len > 0 || line_len > 0)) {
7689 adr_append_line(current_content, (int)sizeof(current_content), &content_len, p,
7690 line_len);
7691 }
7692
7693 p = eol ? eol + SKIP_ONE : p + line_len;
7694 }
7695
7696 adr_save_section(&result, current_section, current_content, content_len);
7697 return result;
7698}
7699
7700/* Append a section to the render buffer.
7701 *

Callers 3

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