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

Function cbm_store_coverage_get

src/store/store.c:3242–3284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3240}
3241
3242int cbm_store_coverage_get(cbm_store_t *s, const char *project, cbm_coverage_row_t **out,
3243 int *count) {
3244 *out = NULL;
3245 *count = 0;
3246 if (!s || !s->db || !project) {
3247 return CBM_STORE_ERR;
3248 }
3249 sqlite3_stmt *stmt = NULL;
3250 if (sqlite3_prepare_v2(s->db,
3251 "SELECT rel_path, kind, detail FROM index_coverage "
3252 "WHERE project = ?1 ORDER BY rel_path, kind;",
3253 CBM_NOT_FOUND, &stmt, NULL) != SQLITE_OK) {
3254 store_set_error_sqlite(s, "coverage get prepare");
3255 return CBM_STORE_ERR;
3256 }
3257 bind_text(stmt, SKIP_ONE, project);
3258 int cap = ST_INIT_CAP_16;
3259 int n = 0;
3260 cbm_coverage_row_t *arr = malloc(cap * sizeof(cbm_coverage_row_t));
3261 int scan_rc6;
3262 while ((scan_rc6 = sqlite3_step(stmt)) == SQLITE_ROW) {
3263 if (n >= cap) {
3264 cap *= ST_GROWTH;
3265 arr = safe_realloc(arr, cap * sizeof(cbm_coverage_row_t));
3266 }
3267 arr[n].rel_path = heap_strdup((const char *)sqlite3_column_text(stmt, 0));
3268 arr[n].kind = heap_strdup((const char *)sqlite3_column_text(stmt, SKIP_ONE));
3269 arr[n].detail = heap_strdup((const char *)sqlite3_column_text(stmt, CBM_SZ_2));
3270 n++;
3271 }
3272 if (scan_rc6 != SQLITE_DONE) { /* SCANCHK:6:stmt */
3273 store_set_error_sqlite(s, "row scan aborted");
3274 sqlite3_finalize(stmt);
3275 cbm_store_free_coverage(arr, n);
3276 *out = NULL;
3277 *count = 0;
3278 return CBM_STORE_ERR;
3279 }
3280 sqlite3_finalize(stmt);
3281 *out = arr;
3282 *count = n;
3283 return CBM_STORE_OK;
3284}
3285
3286void cbm_store_free_coverage(cbm_coverage_row_t *rows, int count) {
3287 if (!rows) {

Callers 6

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