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

Function cbm_store_node_scan_next

src/store/store.c:3600–3636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3598}
3599
3600int cbm_store_node_scan_next(cbm_store_node_scan_t *scan, cbm_node_t *out, int max, int *count) {
3601 *count = 0;
3602 if (!scan || max <= 0) {
3603 return CBM_STORE_OK;
3604 }
3605 if (scan->eager_failed) {
3606 scan->eager_failed = false; /* reported once; the scan then reads as exhausted */
3607 return CBM_STORE_ERR;
3608 }
3609 if (!scan->paged) {
3610 int left = scan->eager_count - scan->eager_next;
3611 int n = left < max ? left : max;
3612 if (n > 0) {
3613 memcpy(out, scan->eager + scan->eager_next, (size_t)n * sizeof(cbm_node_t));
3614 memset(scan->eager + scan->eager_next, 0, (size_t)n * sizeof(cbm_node_t));
3615 scan->eager_next += n;
3616 }
3617 *count = n;
3618 return CBM_STORE_OK;
3619 }
3620 int n = 0;
3621 while (n < max && !scan->done) {
3622 int got = 0;
3623 if (node_scan_page(scan, out + n, max - n, &got) != CBM_STORE_OK) {
3624 /* A failed page yields no rows from this call and ends the scan;
3625 * cbm_store_error() names the failure. */
3626 for (int i = 0; i < n; i++) {
3627 cbm_node_free_fields(&out[i]);
3628 }
3629 scan->done = true;
3630 return CBM_STORE_ERR;
3631 }
3632 n += got;
3633 }
3634 *count = n;
3635 return CBM_STORE_OK;
3636}
3637
3638void cbm_store_node_scan_close(cbm_store_node_scan_t *scan) {
3639 if (!scan) {

Callers 2

start_source_nextFunction · 0.85
scan_matches_eagerFunction · 0.85

Calls 2

node_scan_pageFunction · 0.85
cbm_node_free_fieldsFunction · 0.85

Tested by 1

scan_matches_eagerFunction · 0.68