clang-tidy cleanups (#800)
[openal-soft.git] / core / except.cpp
blobba4759a39b906161ce09a3f25ab64233eccdf21a
2 #include "config.h"
4 #include "except.h"
6 #include <cstdio>
7 #include <cstdarg>
9 #include "opthelpers.h"
12 namespace al {
14 base_exception::~base_exception() = default;
16 void base_exception::setMessage(const char* msg, std::va_list args)
18 std::va_list args2;
19 va_copy(args2, args);
20 int msglen{std::vsnprintf(nullptr, 0, msg, args)};
21 if(msglen > 0) [[likely]]
23 mMessage.resize(static_cast<size_t>(msglen)+1);
24 std::vsnprintf(const_cast<char*>(mMessage.data()), mMessage.length(), msg, args2);
25 mMessage.pop_back();
27 va_end(args2);
30 } // namespace al