From eedc42890fa1358a6639051a39f7e73f8d4d3b07 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 21 Dec 2020 18:00:43 -0800 Subject: Move alexcpt to core --- core/except.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 core/except.cpp (limited to 'core/except.cpp') diff --git a/core/except.cpp b/core/except.cpp new file mode 100644 index 00000000..07bb410a --- /dev/null +++ b/core/except.cpp @@ -0,0 +1,31 @@ + +#include "config.h" + +#include "except.h" + +#include +#include + +#include "opthelpers.h" + + +namespace al { + +/* Defined here to avoid inlining it. */ +base_exception::~base_exception() { } + +void base_exception::setMessage(const char* msg, std::va_list args) +{ + std::va_list args2; + va_copy(args2, args); + int msglen{std::vsnprintf(nullptr, 0, msg, args)}; + if LIKELY(msglen > 0) + { + mMessage.resize(static_cast(msglen)+1); + std::vsnprintf(&mMessage[0], mMessage.length(), msg, args2); + mMessage.pop_back(); + } + va_end(args2); +} + +} // namespace al -- cgit v1.2.3