Addresses #9854.
This installs a handler for failed allocations. Usually, a std::bad_alloc would be thrown, but we can instead opt to terminate immediately. See http://en.cppreference.com/w/cpp/memory/new/set_new_handler .
Our only manual malloc/free comes from prevector. Ideally we’d just use new[]/delete[] there, but the benchmark shows a noticeable difference, and I’m very hesitant to make that kind of change post-rc2.
As an alternative, this could even just be an assert() for 0.14.
For reference, here’s the alternative using new/delete: https://github.com/theuni/bitcoin/commit/0c1b4107b918d457376dcd154f7e87d9d647bf91
Edit: g++/libstdc++ didn’t support get_new_handler() yet, so assert it is.