Add opt.experimental_infallible_new.

This allows a guarantee that operator new never throws.

Fix the .gitignore rules to include test/integration/cpp while we're here.
This commit is contained in:
David Goldblatt 2021-06-21 13:40:30 -07:00 committed by David Goldblatt
parent 0689448b1e
commit 4452a4812f
14 changed files with 134 additions and 3 deletions

View file

@ -56,6 +56,12 @@ void operator delete[](void* ptr, std::size_t size, std::align_val_t al) noexcep
JEMALLOC_NOINLINE
static void *
handleOOM(std::size_t size, bool nothrow) {
if (opt_experimental_infallible_new) {
safety_check_fail("<jemalloc>: Allocation failed and "
"opt.experimental_infallible_new is true. Aborting.\n");
return nullptr;
}
void *ptr = nullptr;
while (ptr == nullptr) {
@ -93,7 +99,6 @@ fallback_impl(std::size_t size) noexcept(IsNoExcept) {
if (likely(ptr != nullptr)) {
return ptr;
}
return handleOOM(size, IsNoExcept);
}