Serialize collected regions as "start-end,start-end,..." into the arena. */
| 1097 | |
| 1098 | /* Serialize collected regions as "start-end,start-end,..." into the arena. */ |
| 1099 | static const char *cbm_error_ranges_str(CBMArena *a, const cbm_error_regions_t *regs) { |
| 1100 | if (regs->count <= 0) { |
| 1101 | return NULL; |
| 1102 | } |
| 1103 | enum { RANGE_MAX = 24 }; /* "4294967295-4294967295," */ |
| 1104 | char *buf = (char *)cbm_arena_alloc(a, (size_t)regs->count * RANGE_MAX); |
| 1105 | if (!buf) { |
| 1106 | return NULL; |
| 1107 | } |
| 1108 | size_t off = 0; |
| 1109 | for (int i = 0; i < regs->count; i++) { |
| 1110 | off += (size_t)snprintf(buf + off, RANGE_MAX, "%s%u-%u", i ? "," : "", regs->starts[i], |
| 1111 | regs->ends[i]); |
| 1112 | } |
| 1113 | return buf; |
| 1114 | } |
| 1115 | |
| 1116 | /* Public entry: run the extraction and journal completion. The DONE mark on |
| 1117 | * every ordinary return (including error/timeout results) tells the crash |
no test coverage detected