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

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

Issue 1039043002: Add base::TerminateBecauseOutOfMemory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Thu Mar 26 16:12:29 PDT 2015 Created 5 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/logging.h"
5 #include "base/process/memory.h" 6 #include "base/process/memory.h"
6 7
7 namespace base { 8 namespace base {
8 9
10 namespace {
11
12 // Breakpad server already classifies base::`anonymous namespace'::OnNoMemory as
13 // out-of-memory crash.
14 NOINLINE void OnNoMemory() {
reveman 2015/03/27 05:05:20 We seem to have different implementations of this
Vitaly Buka (NO REVIEWS) 2015/03/27 06:29:13 I guess it's just historical, I see no good reason
reveman 2015/03/27 13:04:50 Looks like the return type of OnNoMemory is differ
15 LOG(FATAL) << "Out of memory.";
16 }
17
18 } // namespace
19
20 void CrashWithOutOfMemory() {
21 OnNoMemory();
22 }
23
9 // Defined in memory_mac.mm for Mac. 24 // Defined in memory_mac.mm for Mac.
10 #if !defined(OS_MACOSX) 25 #if !defined(OS_MACOSX)
11 26
12 bool UncheckedCalloc(size_t num_items, size_t size, void** result) { 27 bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
13 const size_t alloc_size = num_items * size; 28 const size_t alloc_size = num_items * size;
14 29
15 // Overflow check 30 // Overflow check
16 if (size && ((alloc_size / size) != num_items)) { 31 if (size && ((alloc_size / size) != num_items)) {
17 *result = NULL; 32 *result = NULL;
18 return false; 33 return false;
19 } 34 }
20 35
21 if (!UncheckedMalloc(alloc_size, result)) 36 if (!UncheckedMalloc(alloc_size, result))
22 return false; 37 return false;
23 38
24 memset(*result, 0, alloc_size); 39 memset(*result, 0, alloc_size);
25 return true; 40 return true;
26 } 41 }
27 42
28 #endif 43 #endif
29 44
30 } // namespace base 45 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698