| 235 | } |
| 236 | |
| 237 | void error_vprintf(const char* pFmt, va_list args) |
| 238 | { |
| 239 | const uint32_t BUF_SIZE = 256; |
| 240 | char buf[BUF_SIZE]; |
| 241 | |
| 242 | va_list args_copy; |
| 243 | va_copy(args_copy, args); |
| 244 | int total_chars = vsnprintf(buf, sizeof(buf), pFmt, args_copy); |
| 245 | va_end(args_copy); |
| 246 | |
| 247 | if (total_chars < 0) |
| 248 | { |
| 249 | assert(0); |
| 250 | return; |
| 251 | } |
| 252 | |
| 253 | fflush(stdout); |
| 254 | |
| 255 | if (total_chars >= (int)BUF_SIZE) |
| 256 | { |
| 257 | basisu::vector<char> var_buf(total_chars + 1); |
| 258 | |
| 259 | va_copy(args_copy, args); |
| 260 | int total_chars_retry = vsnprintf(var_buf.data(), var_buf.size(), pFmt, args_copy); |
| 261 | va_end(args_copy); |
| 262 | |
| 263 | if (total_chars_retry < 0) |
| 264 | { |
| 265 | assert(0); |
| 266 | return; |
| 267 | } |
| 268 | |
| 269 | fprintf(stderr, "ERROR: %s", var_buf.data()); |
| 270 | } |
| 271 | else |
| 272 | { |
| 273 | fprintf(stderr, "ERROR: %s", buf); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | void error_printf(const char *pFmt, ...) |
| 278 | { |
no test coverage detected