aboutsummaryrefslogtreecommitdiffstats
path: root/common/alexcpt.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-12-12 19:21:00 +0100
committerSven Gothel <[email protected]>2019-12-12 19:21:00 +0100
commit4df06c6894b39af5bf4681c0acf0c1c080084c80 (patch)
tree2505eb6e3b5798db34033c4cac2d4613bf6bda44 /common/alexcpt.cpp
parent8915501ed02eac2b3bce9a7fc06cb1ab562901c3 (diff)
parentc0cf323e1d56ce605e90927324d2fdafcfbb564a (diff)
merge v1.20.0
Diffstat (limited to 'common/alexcpt.cpp')
-rw-r--r--common/alexcpt.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/common/alexcpt.cpp b/common/alexcpt.cpp
new file mode 100644
index 00000000..5055e34f
--- /dev/null
+++ b/common/alexcpt.cpp
@@ -0,0 +1,30 @@
+
+#include "config.h"
+
+#include "alexcpt.h"
+
+#include <cstdio>
+#include <cstdarg>
+
+#include "opthelpers.h"
+
+
+namespace al {
+
+backend_exception::backend_exception(ALCenum code, const char *msg, ...) : mErrorCode{code}
+{
+ va_list args, args2;
+ va_start(args, msg);
+ va_copy(args2, args);
+ int msglen{std::vsnprintf(nullptr, 0, msg, args)};
+ if LIKELY(msglen > 0)
+ {
+ mMessage.resize(static_cast<size_t>(msglen)+1);
+ std::vsnprintf(&mMessage[0], mMessage.length(), msg, args2);
+ mMessage.pop_back();
+ }
+ va_end(args2);
+ va_end(args);
+}
+
+} // namespace al