Fix error: cannot use 'throw' with exceptions disabled

`mimalloc` should compile even if exceptions are disabled by the MSVC
or GCC or Clang command-line options.
This commit is contained in:
Sergey 2023-09-05 15:55:43 -07:00 committed by Sergey Markelov
parent 4e50d6714d
commit 2f42773cd7

View file

@ -913,9 +913,13 @@ static bool mi_try_new_handler(bool nothrow) {
#endif
if (h==NULL) {
_mi_error_message(ENOMEM, "out of memory in 'new'");
#if defined(_CPPUNWIND) || defined(__cpp_exceptions)
if (!nothrow) {
throw std::bad_alloc();
}
#else
(void)nothrow;
#endif
return false;
}
else {