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

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

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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.h ('k') | base/process/memory_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/debug/alias.h"
6 #include "base/logging.h"
7 #include "base/process/memory.h"
8
9 namespace base {
10
11 namespace {
12
13 // Breakpad server classifies base::`anonymous namespace'::OnNoMemory as
14 // out-of-memory crash.
15 NOINLINE void OnNoMemory(size_t size) {
16 size_t tmp_size = size;
17 base::debug::Alias(&tmp_size);
18 LOG(FATAL) << "Out of memory. size=" << tmp_size;
19 }
20
21 } // namespace
22
23 void TerminateBecauseOutOfMemory(size_t size) {
24 OnNoMemory(size);
25 }
26
27 // Defined in memory_mac.mm for Mac.
28 #if !defined(OS_MACOSX)
29
30 bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
31 const size_t alloc_size = num_items * size;
32
33 // Overflow check
34 if (size && ((alloc_size / size) != num_items)) {
35 *result = NULL;
36 return false;
37 }
38
39 if (!UncheckedMalloc(alloc_size, result))
40 return false;
41
42 memset(*result, 0, alloc_size);
43 return true;
44 }
45
46 #endif
47
48 #if defined(OS_NACL)
49 bool UncheckedMalloc(size_t size, void** result) {
50 *result = malloc(size);
51 return *result != NULL;
52 }
53 #endif
54
55 } // namespace base
OLDNEW
« no previous file with comments | « base/process/memory.h ('k') | base/process/memory_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698