| // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #include "base/process/memory.h" |
| #include "build_config.h" |
| TerminateBecauseOutOfMemory(0); |
| void EnableTerminationOnHeapCorruption() { |
| DLOG(WARNING) << "EnableTerminationOnHeapCorruption only works on 64-bit"; |
| bool UncheckedMalloc(size_t size, void** result) { |
| return *result != nullptr; |
| bool UncheckedCalloc(size_t num_items, size_t size, void** result) { |
| *result = calloc(num_items, size); |
| return *result != nullptr; |
| void EnableTerminationOnOutOfMemory() { |
| // Step 1: Enable OOM killer on C++ failures. |
| std::set_new_handler(oom_killer_new); |
| // Step 2: Enable OOM killer on all other malloc zones (or just "all" without |
| // "other" if shim is disabled). |
| allocator::InterceptAllocationsMac(); |