mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-15 15:11:41 +03:00
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:
parent
0689448b1e
commit
4452a4812f
14 changed files with 134 additions and 3 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue