🛠️🐜 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.

30 lines
600 B

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