Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: base/process/memory_stubs.cc

Issue 2173463002: Make base::TerminateBecauseOutOfMemory call RaiseException on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: implement in memory_stubs Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/process/memory.cc ('k') | base/process/memory_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/process/memory.h" 5 #include "base/process/memory.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 namespace base { 10 namespace base {
11 11
12 void EnableTerminationOnOutOfMemory() { 12 void EnableTerminationOnOutOfMemory() {
13 } 13 }
14 14
15 void EnableTerminationOnHeapCorruption() { 15 void EnableTerminationOnHeapCorruption() {
16 } 16 }
17 17
18 bool AdjustOOMScore(ProcessId process, int score) { 18 bool AdjustOOMScore(ProcessId process, int score) {
19 return false; 19 return false;
20 } 20 }
21 21
22 void TerminateBecauseOutOfMemory(size_t size) {
23 abort();
24 }
25
22 // UncheckedMalloc and Calloc exist so that platforms making use of 26 // UncheckedMalloc and Calloc exist so that platforms making use of
23 // EnableTerminationOnOutOfMemory have a way to allocate memory without 27 // EnableTerminationOnOutOfMemory have a way to allocate memory without
24 // crashing. This _stubs.cc file is for platforms that do not support 28 // crashing. This _stubs.cc file is for platforms that do not support
25 // EnableTerminationOnOutOfMemory (note the empty implementation above). As 29 // EnableTerminationOnOutOfMemory (note the empty implementation above). As
26 // such, these two Unchecked.alloc functions need only trivially pass-through to 30 // 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 31 // their respective stdlib function since those functions will return null on a
28 // failure to allocate. 32 // failure to allocate.
29 33
30 bool UncheckedMalloc(size_t size, void** result) { 34 bool UncheckedMalloc(size_t size, void** result) {
31 *result = malloc(size); 35 *result = malloc(size);
32 return *result != nullptr; 36 return *result != nullptr;
33 } 37 }
34 38
35 bool UncheckedCalloc(size_t num_items, size_t size, void** result) { 39 bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
36 *result = calloc(num_items, size); 40 *result = calloc(num_items, size);
37 return *result != nullptr; 41 return *result != nullptr;
38 } 42 }
39 43
40 } // namespace base 44 } // namespace base
OLDNEW
« no previous file with comments | « base/process/memory.cc ('k') | base/process/memory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698