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

Function adr_save_section

src/store/store.c:10994–11011  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

10992
10993/* Save a completed ADR section into result, trimming whitespace. */
10994static void adr_save_section(cbm_adr_sections_t *result, char *section_name, char *buf,
10995 int buf_len) {
10996 if (!section_name || result->count >= ST_BUF_16) {
10997 return;
10998 }
10999 /* Trim trailing whitespace */
11000 while (buf_len > 0 && (buf[buf_len - SKIP_ONE] == '\n' || buf[buf_len - SKIP_ONE] == ' ')) {
11001 buf[--buf_len] = '\0';
11002 }
11003 /* Skip leading whitespace */
11004 char *trimmed = buf;
11005 while (*trimmed == '\n' || *trimmed == ' ') {
11006 trimmed++;
11007 }
11008 result->keys[result->count] = section_name;
11009 result->values[result->count] = heap_strdup(trimmed);
11010 result->count++;
11011}
11012
11013/* Try to extract a canonical section header from a "## Header" line.
11014 * 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