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

Function cbm_error_ranges_str

internal/cbm/cbm.c:1592–1610  ·  view source on GitHub ↗

Serialize collected regions as "start-end,start-end,...", with a trailing * ",+ " when the cap threw N ranges away. * * The marker must stay a SUFFIX and nothing else. Every reader stops at the * first token that is not a range, so a marker in the middle of a string * silently hides everything after it. objectscript_export_append_error_ranges * strips markers before joining two parts for e

Source from the content-addressed store, hash-verified

1590 * macro rules run after collection and remove ranges the cap never saw. That
1591 * still reports honestly: the cap bound, so what was lost is unknown. */
1592static const char *cbm_error_ranges_str(CBMArena *a, const cbm_error_regions_t *regs) {
1593 if (regs->count <= 0 && regs->dropped <= 0) {
1594 return NULL;
1595 }
1596 enum { RANGE_MAX = 24 }; /* "4294967295-4294967295," */
1597 char *buf = (char *)cbm_arena_alloc(a, (size_t)(regs->count + 1) * RANGE_MAX);
1598 if (!buf) {
1599 return NULL;
1600 }
1601 size_t off = 0;
1602 for (int i = 0; i < regs->count; i++) {
1603 off += (size_t)snprintf(buf + off, RANGE_MAX, "%s%u-%u", i ? "," : "", regs->starts[i],
1604 regs->ends[i]);
1605 }
1606 if (regs->dropped > 0) {
1607 snprintf(buf + off, RANGE_MAX, "%s+%d", off ? "," : "", regs->dropped);
1608 }
1609 return buf;
1610}
1611
1612/* Public entry: run the extraction and journal completion. The DONE mark on
1613 * every ordinary return (including error/timeout results) tells the crash

Callers 1

extract_file_ex_bodyFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected