1 // Copyright 2017 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "base/process/memory.h" 6 7 #include "partition_alloc/partition_alloc_buildflags.h" 8 9 #if BUILDFLAG(USE_ALLOCATOR_SHIM) 10 #include "partition_alloc/shim/allocator_shim.h" 11 #endif 12 13 #include <stdlib.h> 14 15 namespace base { 16 EnableTerminationOnOutOfMemory()17void EnableTerminationOnOutOfMemory() { 18 // Nothing to be done here. 19 } 20 EnableTerminationOnHeapCorruption()21void EnableTerminationOnHeapCorruption() { 22 // Nothing to be done here. 23 } 24 UncheckedMalloc(size_t size,void ** result)25bool UncheckedMalloc(size_t size, void** result) { 26 #if BUILDFLAG(USE_ALLOCATOR_SHIM) 27 *result = allocator_shim::UncheckedAlloc(size); 28 #else 29 *result = malloc(size); 30 #endif 31 return *result != nullptr; 32 } 33 UncheckedFree(void * ptr)34void UncheckedFree(void* ptr) { 35 #if BUILDFLAG(USE_ALLOCATOR_SHIM) 36 allocator_shim::UncheckedFree(ptr); 37 #else 38 free(ptr); 39 #endif 40 } 41 42 } // namespace base 43