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

Function mcp_search_cache_open

tests/test_mcp.c:219–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219static bool mcp_search_cache_open(mcp_search_cache_t *cache, const char *prefix) {
220 memset(cache, 0, sizeof(*cache));
221 snprintf(cache->path, sizeof(cache->path), "%s/%s-XXXXXX", cbm_tmpdir(), prefix);
222 if (!cbm_mkdtemp(cache->path)) {
223 return false;
224 }
225 const char *saved_cache = getenv("CBM_CACHE_DIR");
226 cache->saved_cache = saved_cache ? strdup(saved_cache) : NULL;
227 if ((saved_cache && !cache->saved_cache) || cbm_setenv("CBM_CACHE_DIR", cache->path, 1) != 0) {
228 free(cache->saved_cache);
229 cache->saved_cache = NULL;
230 (void)th_rmtree(cache->path);
231 return false;
232 }
233 return true;
234}
235
236static bool mcp_search_cache_close(mcp_search_cache_t *cache) {
237 restore_cache_dir(cache->saved_cache);

Callers 1

test_mcp.cFile · 0.85

Calls 4

cbm_tmpdirFunction · 0.85
cbm_mkdtempFunction · 0.85
cbm_setenvFunction · 0.85
th_rmtreeFunction · 0.85

Tested by

no test coverage detected