• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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 <stddef.h>
8 #include <stdlib.h>
9 
10 namespace base {
11 
EnableTerminationOnOutOfMemory()12 void EnableTerminationOnOutOfMemory() {
13 }
14 
EnableTerminationOnHeapCorruption()15 void EnableTerminationOnHeapCorruption() {
16 }
17 
AdjustOOMScore(ProcessId process,int score)18 bool AdjustOOMScore(ProcessId process, int score) {
19   return false;
20 }
21 
22 // UncheckedMalloc and Calloc exist so that platforms making use of
23 // EnableTerminationOnOutOfMemory have a way to allocate memory without
24 // crashing. This _stubs.cc file is for platforms that do not support
25 // EnableTerminationOnOutOfMemory (note the empty implementation above). As
26 // such, these two Unchecked.alloc functions need only trivially pass-through to
27 // their respective stdlib function since those functions will return null on a
28 // failure to allocate.
29 
UncheckedMalloc(size_t size,void ** result)30 bool UncheckedMalloc(size_t size, void** result) {
31   *result = malloc(size);
32   return *result != nullptr;
33 }
34 
UncheckedCalloc(size_t num_items,size_t size,void ** result)35 bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
36   *result = calloc(num_items, size);
37   return *result != nullptr;
38 }
39 
UncheckedFree(void * ptr)40 void UncheckedFree(void* ptr) {
41   free(ptr);
42 }
43 
44 }  // namespace base
45