🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
610 B

  1. #include "config.h"
  2. #include "except.h"
  3. #include <cstdio>
  4. #include <cstdarg>
  5. #include "opthelpers.h"
  6. namespace al {
  7. /* Defined here to avoid inlining it. */
  8. base_exception::~base_exception() { }
  9. void base_exception::setMessage(const char* msg, std::va_list args)
  10. {
  11. std::va_list args2;
  12. va_copy(args2, args);
  13. int msglen{std::vsnprintf(nullptr, 0, msg, args)};
  14. if LIKELY(msglen > 0)
  15. {
  16. mMessage.resize(static_cast<size_t>(msglen)+1);
  17. std::vsnprintf(&mMessage[0], mMessage.length(), msg, args2);
  18. mMessage.pop_back();
  19. }
  20. va_end(args2);
  21. }
  22. } // namespace al