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

Function dm_tree_work

tests/test_doc_mentions.c:8574–8602  ·  view source on GitHub ↗

What the resolver looks at to find the project of DM_TREE_FILES files that * stand `depth` directories deep, in a repository without a project file. */

Source from the content-addressed store, hash-verified

8572/* What the resolver looks at to find the project of DM_TREE_FILES files that
8573 * stand `depth` directories deep, in a repository without a project file. */
8574static uint64_t dm_tree_work(int depth) {
8575 char tmp[256];
8576 char dir[256];
8577 char rel[320];
8578 char text[192];
8579 snprintf(tmp, sizeof(tmp), "/tmp/cbm_dm_tree_XXXXXX");
8580 if (depth * 2 >= (int)sizeof(dir) || !cbm_mkdtemp(tmp)) {
8581 return 0;
8582 }
8583 size_t d = 0;
8584 dir[0] = '\0';
8585 for (int i = 0; i < depth; i++) {
8586 d += (size_t)snprintf(dir + d, sizeof(dir) - d, "d/");
8587 }
8588 for (int i = 0; i < DM_TREE_FILES; i++) {
8589 snprintf(rel, sizeof(rel), "%sF%03d.cs", dir, i);
8590 snprintf(text, sizeof(text), "namespace Deep\n{\n%s public class F%03d { }\n}\n",
8591 i == 0 ? " /// <summary><see cref=\"Nowhere\"/></summary>\n" : "", i);
8592 th_write_file(TH_PATH(tmp, rel), text);
8593 }
8594 char db[512];
8595 snprintf(db, sizeof(db), "%s/cost.db", tmp);
8596 cbm_doclink_cs_test_work_reset();
8597 uint64_t work = dm_index(tmp, db, NULL) == 0 ? cbm_doclink_cs_test_work() : 0;
8598 int rows = dm_count(db, "SELECT COUNT(*) FROM doc_link_unresolved");
8599 dm_unlink_db(db);
8600 th_rmtree(tmp);
8601 return rows == 1 ? work : 0;
8602}
8603
8604/* Every import kind is queried with names absent everywhere or declared only
8605 * outside the imported scopes. Count visits/probes, never elapsed time. */

Callers 1

Calls 8

cbm_mkdtempFunction · 0.85
th_write_fileFunction · 0.85
dm_indexFunction · 0.85
cbm_doclink_cs_test_workFunction · 0.85
dm_countFunction · 0.85
dm_unlink_dbFunction · 0.85
th_rmtreeFunction · 0.85

Tested by

no test coverage detected