| 404 | // |
| 405 | |
| 406 | static std::string string_format(const char * fmt, ...) { |
| 407 | va_list ap; |
| 408 | va_list ap2; |
| 409 | va_start(ap, fmt); |
| 410 | va_copy(ap2, ap); |
| 411 | int size = vsnprintf(NULL, 0, fmt, ap); |
| 412 | GGML_ASSERT(size >= 0 && size < INT_MAX); // NOLINT |
| 413 | std::vector<char> buf(size + 1); |
| 414 | int size2 = vsnprintf(buf.data(), size + 1, fmt, ap2); |
| 415 | GGML_ASSERT(size2 == size); |
| 416 | va_end(ap2); |
| 417 | va_end(ap); |
| 418 | return std::string(buf.data(), buf.size()); |
| 419 | } |
| 420 | |
| 421 | static void string_replace_all(std::string & s, const std::string & search, const std::string & replace) { |
| 422 | if (search.empty()) { |
no test coverage detected