MCPcopy Create free account
hub / github.com/ashaduri/gsmartcontrol / string_vsprintf_get_buffer_size

Function string_vsprintf_get_buffer_size

src/hz/string_sprintf.h:93–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91
92
93inline 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

Callers 2

string_vsprintfFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected