revert broken commit. Isaac doesn't know what he's doing.
This commit is contained in:
parent
a0c34f0d96
commit
cb30f7639f
|
@ -120,16 +120,18 @@ std::string Join(const StringVector &values, const std::string &delim) {
|
||||||
std::string stringtf(const char* format, ...) {
|
std::string stringtf(const char* format, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
int size = vsnprintf(nullptr, 0, format, args) + 1; // Extra space for '\0'
|
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
if (size <= 0) {
|
|
||||||
throw std::runtime_error("Error during formatting.");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<char[]> buf(new char[size]);
|
|
||||||
va_list args2;
|
va_list args2;
|
||||||
va_copy(args2, args);
|
va_copy(args2, args);
|
||||||
|
int size = vsnprintf(nullptr, 0, format, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
if (size < 0) {
|
||||||
|
va_end(args2);
|
||||||
|
throw std::runtime_error("Error during formatting.");
|
||||||
|
}
|
||||||
|
size += 1; // Extra space for '\0'
|
||||||
|
|
||||||
|
std::unique_ptr<char[]> buf(new char[size]);
|
||||||
vsnprintf(buf.get(), size, format, args2);
|
vsnprintf(buf.get(), size, format, args2);
|
||||||
va_end(args2);
|
va_end(args2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue