]> git.tdb.fi Git - ext/openal.git/blob - core/except.cpp
Import OpenAL Soft 1.23.1 sources
[ext/openal.git] / core / except.cpp
1
2 #include "config.h"
3
4 #include "except.h"
5
6 #include <cstdio>
7 #include <cstdarg>
8
9 #include "opthelpers.h"
10
11
12 namespace al {
13
14 base_exception::~base_exception() = default;
15
16 void base_exception::setMessage(const char* msg, std::va_list args)
17 {
18     std::va_list args2;
19     va_copy(args2, args);
20     int msglen{std::vsnprintf(nullptr, 0, msg, args)};
21     if(msglen > 0) LIKELY
22     {
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();
26     }
27     va_end(args2);
28 }
29
30 } // namespace al