fix: correct usage of C func

This commit is contained in:
2025-11-28 23:13:04 +01:00
parent fd5b0da1af
commit 3231438f20

View File

@@ -30,11 +30,15 @@ namespace utils::string
while (true)
{
const auto res = vsnprintf(entry->buffer_, entry->size_, format, ap);
if (res < 0) return nullptr; // Error
if (res > 0) break; // Success
if (res == 0) return nullptr; // Error
if (static_cast<std::size_t>(res) >= entry->size_)
{
entry->double_size();
continue;
}
break; // Success
}
return entry->buffer_;