| 219 | static _Atomic(size_t) out_len; |
| 220 | |
| 221 | static void mi_cdecl mi_out_buf(const char* msg, void* arg) { |
| 222 | MI_UNUSED(arg); |
| 223 | if (msg==NULL) return; |
| 224 | if (mi_atomic_load_relaxed(&out_len)>=MI_MAX_DELAY_OUTPUT) return; |
| 225 | size_t n = strlen(msg); |
| 226 | if (n==0) return; |
| 227 | // claim space |
| 228 | size_t start = mi_atomic_add_acq_rel(&out_len, n); |
| 229 | if (start >= MI_MAX_DELAY_OUTPUT) return; |
| 230 | // check bound |
| 231 | if (start+n >= MI_MAX_DELAY_OUTPUT) { |
| 232 | n = MI_MAX_DELAY_OUTPUT-start-1; |
| 233 | } |
| 234 | _mi_memcpy(&out_buf[start], msg, n); |
| 235 | } |
| 236 | |
| 237 | static void mi_out_buf_flush(mi_output_fun* out, bool no_more_buf, void* arg) { |
| 238 | if (out==NULL) return; |
no test coverage detected