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

Function cbm_error_ranges_str

internal/cbm/cbm.c:2805–2823  ·  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

2803 * macro rules run after collection and remove ranges the cap never saw. That
2804 * still reports honestly: the cap bound, so what was lost is unknown. */
2805static const char *cbm_error_ranges_str(CBMArena *a, const cbm_error_regions_t *regs) {
2806 if (regs->count <= 0 && regs->dropped <= 0) {
2807 return NULL;
2808 }
2809 enum { RANGE_MAX = 24 }; /* "4294967295-4294967295," */
2810 char *buf = (char *)cbm_arena_alloc(a, (size_t)(regs->count + 1) * RANGE_MAX);
2811 if (!buf) {
2812 return NULL;
2813 }
2814 size_t off = 0;
2815 for (int i = 0; i < regs->count; i++) {
2816 off += (size_t)snprintf(buf + off, RANGE_MAX, "%s%u-%u", i ? "," : "", regs->starts[i],
2817 regs->ends[i]);
2818 }
2819 if (regs->dropped > 0) {
2820 snprintf(buf + off, RANGE_MAX, "%s+%d", off ? "," : "", regs->dropped);
2821 }
2822 return buf;
2823}
2824
2825/* ── Same-file duplicate definitions: the `variants` property ──────────────
2826 *

Callers 1

extract_file_ex_bodyFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected