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

Function adr_save_section

src/store/store.c:5666–5683  ·  view source on GitHub ↗

Save a completed ADR section into result, trimming whitespace. */

Source from the content-addressed store, hash-verified

5664
5665/* Save a completed ADR section into result, trimming whitespace. */
5666static void adr_save_section(cbm_adr_sections_t *result, char *section_name, char *buf,
5667 int buf_len) {
5668 if (!section_name || result->count >= ST_BUF_16) {
5669 return;
5670 }
5671 /* Trim trailing whitespace */
5672 while (buf_len > 0 && (buf[buf_len - SKIP_ONE] == '\n' || buf[buf_len - SKIP_ONE] == ' ')) {
5673 buf[--buf_len] = '\0';
5674 }
5675 /* Skip leading whitespace */
5676 char *trimmed = buf;
5677 while (*trimmed == '\n' || *trimmed == ' ') {
5678 trimmed++;
5679 }
5680 result->keys[result->count] = section_name;
5681 result->values[result->count] = heap_strdup(trimmed);
5682 result->count++;
5683}
5684
5685/* Try to extract a canonical section header from a "## Header" line.
5686 * Returns heap-allocated header string if canonical, NULL otherwise. */

Callers 1

cbm_adr_parse_sectionsFunction · 0.85

Calls 1

heap_strdupFunction · 0.70

Tested by

no test coverage detected