Serialize collected regions as "start-end,start-end,..." into the arena. */
| 1133 | |
| 1134 | /* Serialize collected regions as "start-end,start-end,..." into the arena. */ |
| 1135 | static const char *cbm_error_ranges_str(CBMArena *a, const cbm_error_regions_t *regs) { |
| 1136 | if (regs->count <= 0) { |
| 1137 | return NULL; |
| 1138 | } |
| 1139 | enum { RANGE_MAX = 24 }; /* "4294967295-4294967295," */ |
| 1140 | char *buf = (char *)cbm_arena_alloc(a, (size_t)regs->count * RANGE_MAX); |
| 1141 | if (!buf) { |
| 1142 | return NULL; |
| 1143 | } |
| 1144 | size_t off = 0; |
| 1145 | for (int i = 0; i < regs->count; i++) { |
| 1146 | off += (size_t)snprintf(buf + off, RANGE_MAX, "%s%u-%u", i ? "," : "", regs->starts[i], |
| 1147 | regs->ends[i]); |
| 1148 | } |
| 1149 | return buf; |
| 1150 | } |
| 1151 | |
| 1152 | /* Public entry: run the extraction and journal completion. The DONE mark on |
| 1153 | * every ordinary return (including error/timeout results) tells the crash |
no test coverage detected