| 91 | |
| 92 | |
| 93 | inline int string_vsprintf_get_buffer_size(const char* format, std::va_list ap) |
| 94 | { |
| 95 | #if defined ENABLE_GLIB && ENABLE_GLIB |
| 96 | // the glib version returns gsize |
| 97 | return static_cast<int>(g_printf_string_upper_bound(format, ap)); |
| 98 | |
| 99 | #else |
| 100 | // In C++11, vsnprintf() returns the number of bytes it could have written |
| 101 | // (without \0) if buffer was large enough. |
| 102 | // This includes mingw/ISO. |
| 103 | const int size = std::vsnprintf(nullptr, 0, format, ap); // C99 and others |
| 104 | if (size < 0) |
| 105 | return -1; |
| 106 | return size + 1; // that +1 is for \0. |
| 107 | #endif |
| 108 | } |
| 109 | |
| 110 | |
| 111 |
no outgoing calls
no test coverage detected