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

Function resolve_snippet_source

src/mcp/mcp.c:8346–8361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8344}
8345
8346static char *resolve_snippet_source(const char *root_path, const char *file_path, int start,
8347 int end, char **out_abs_path) {
8348 *out_abs_path = NULL;
8349 if (!root_path || !file_path) {
8350 return NULL;
8351 }
8352 size_t apsz = strlen(root_path) + strlen(file_path) + MCP_SEPARATOR;
8353 char *abs_path = malloc(apsz);
8354 snprintf(abs_path, apsz, "%s/%s", root_path, file_path);
8355
8356 *out_abs_path = abs_path;
8357 if (cbm_path_within_root(root_path, abs_path)) {
8358 return read_file_lines(abs_path, start, end);
8359 }
8360 return NULL;
8361}
8362
8363static bool utf8_is_cont(unsigned char c) {
8364 return (c & 0xC0) == 0x80;

Callers 1

build_snippet_responseFunction · 0.85

Calls 2

cbm_path_within_rootFunction · 0.85
read_file_linesFunction · 0.85

Tested by

no test coverage detected