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

Function cbm_store_coverage_get

src/store/store.c:3259–3301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3257}
3258
3259int cbm_store_coverage_get(cbm_store_t *s, const char *project, cbm_coverage_row_t **out,
3260 int *count) {
3261 *out = NULL;
3262 *count = 0;
3263 if (!s || !s->db || !project) {
3264 return CBM_STORE_ERR;
3265 }
3266 sqlite3_stmt *stmt = NULL;
3267 if (sqlite3_prepare_v2(s->db,
3268 "SELECT rel_path, kind, detail FROM index_coverage "
3269 "WHERE project = ?1 ORDER BY rel_path, kind;",
3270 CBM_NOT_FOUND, &stmt, NULL) != SQLITE_OK) {
3271 store_set_error_sqlite(s, "coverage get prepare");
3272 return CBM_STORE_ERR;
3273 }
3274 bind_text(stmt, SKIP_ONE, project);
3275 int cap = ST_INIT_CAP_16;
3276 int n = 0;
3277 cbm_coverage_row_t *arr = malloc(cap * sizeof(cbm_coverage_row_t));
3278 int scan_rc6;
3279 while ((scan_rc6 = sqlite3_step(stmt)) == SQLITE_ROW) {
3280 if (n >= cap) {
3281 cap *= ST_GROWTH;
3282 arr = safe_realloc(arr, cap * sizeof(cbm_coverage_row_t));
3283 }
3284 arr[n].rel_path = heap_strdup((const char *)sqlite3_column_text(stmt, 0));
3285 arr[n].kind = heap_strdup((const char *)sqlite3_column_text(stmt, SKIP_ONE));
3286 arr[n].detail = heap_strdup((const char *)sqlite3_column_text(stmt, CBM_SZ_2));
3287 n++;
3288 }
3289 if (scan_rc6 != SQLITE_DONE) { /* SCANCHK:6:stmt */
3290 store_set_error_sqlite(s, "row scan aborted");
3291 sqlite3_finalize(stmt);
3292 cbm_store_free_coverage(arr, n);
3293 *out = NULL;
3294 *count = 0;
3295 return CBM_STORE_ERR;
3296 }
3297 sqlite3_finalize(stmt);
3298 *out = arr;
3299 *count = n;
3300 return CBM_STORE_OK;
3301}
3302
3303void cbm_store_free_coverage(cbm_coverage_row_t *rows, int count) {
3304 if (!rows) {

Callers 7

cov_rebuild_shadow_graphFunction · 0.85
add_coverage_reportFunction · 0.85
test_pipeline.cFile · 0.85
test_store_nodes.cFile · 0.85

Calls 5

store_set_error_sqliteFunction · 0.85
bind_textFunction · 0.85
safe_reallocFunction · 0.85
cbm_store_free_coverageFunction · 0.85
heap_strdupFunction · 0.70

Tested by

no test coverage detected