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

Function cbm_adr_parse_sections

src/store/store.c:7860–7892  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7858}
7859
7860cbm_adr_sections_t cbm_adr_parse_sections(const char *content) {
7861 cbm_adr_sections_t result;
7862 memset(&result, 0, sizeof(result));
7863 if (!content || !content[0]) {
7864 return result;
7865 }
7866
7867 const char *p = content;
7868 char *current_section = NULL;
7869 char current_content[ST_SQL_BUF] = "";
7870 int content_len = 0;
7871
7872 while (*p) {
7873 const char *eol = strchr(p, '\n');
7874 int line_len = eol ? (int)(eol - p) : (int)strlen(p);
7875
7876 char *new_section = adr_try_section_header(p, line_len);
7877 if (new_section) {
7878 adr_save_section(&result, current_section, current_content, content_len);
7879 current_section = new_section;
7880 current_content[0] = '\0';
7881 content_len = 0;
7882 } else if (current_section && (content_len > 0 || line_len > 0)) {
7883 adr_append_line(current_content, (int)sizeof(current_content), &content_len, p,
7884 line_len);
7885 }
7886
7887 p = eol ? eol + SKIP_ONE : p + line_len;
7888 }
7889
7890 adr_save_section(&result, current_section, current_content, content_len);
7891 return result;
7892}
7893
7894/* Append a section to the render buffer.
7895 *

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