mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 05:51:27 +12:00
fmt::format fixed
This commit is contained in:
parent
5fe3ea6440
commit
d1f31d6fda
1 changed files with 4 additions and 4 deletions
|
@ -242,13 +242,13 @@ namespace fmt
|
||||||
// fixed stack buffer for the first attempt
|
// fixed stack buffer for the first attempt
|
||||||
std::array<char, 4096> fixed_buf;
|
std::array<char, 4096> fixed_buf;
|
||||||
|
|
||||||
// possibly dynamically allocated buffer for additional attempts
|
// possibly dynamically allocated buffer for the second attempt
|
||||||
std::unique_ptr<char[]> buf;
|
std::unique_ptr<char[]> buf;
|
||||||
|
|
||||||
// pointer to the current buffer
|
// pointer to the current buffer
|
||||||
char* buf_addr = fixed_buf.data();
|
char* buf_addr = fixed_buf.data();
|
||||||
|
|
||||||
for (std::size_t buf_size = fixed_buf.size();; buf.reset(buf_addr = new char[buf_size]))
|
for (std::size_t buf_size = fixed_buf.size();;)
|
||||||
{
|
{
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wformat-security"
|
#pragma GCC diagnostic ignored "-Wformat-security"
|
||||||
|
@ -261,12 +261,12 @@ namespace fmt
|
||||||
throw std::runtime_error("std::snprintf() failed");
|
throw std::runtime_error("std::snprintf() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len <= buf_size)
|
if (len < buf_size)
|
||||||
{
|
{
|
||||||
return{ buf_addr, len };
|
return{ buf_addr, len };
|
||||||
}
|
}
|
||||||
|
|
||||||
buf_size = len;
|
buf.reset(buf_addr = new char[buf_size = len + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue