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

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

Issue 2601573002: mac: Hook up allocator shim. (Closed)
Patch Set: Clean up. Created 3 years, 12 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/debug/alias.h" 5 #include "base/debug/alias.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/process/memory.h" 7 #include "base/process/memory.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 12 matching lines...) Expand all
23 } 23 }
24 24
25 } // namespace 25 } // namespace
26 26
27 void TerminateBecauseOutOfMemory(size_t size) { 27 void TerminateBecauseOutOfMemory(size_t size) {
28 OnNoMemory(size); 28 OnNoMemory(size);
29 } 29 }
30 30
31 #endif 31 #endif
32 32
33 // Defined in memory_mac.mm for Mac.
34 #if !defined(OS_MACOSX)
35
36 bool UncheckedCalloc(size_t num_items, size_t size, void** result) { 33 bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
37 const size_t alloc_size = num_items * size; 34 const size_t alloc_size = num_items * size;
38 35
39 // Overflow check 36 // Overflow check
40 if (size && ((alloc_size / size) != num_items)) { 37 if (size && ((alloc_size / size) != num_items)) {
41 *result = NULL; 38 *result = NULL;
42 return false; 39 return false;
43 } 40 }
44 41
45 if (!UncheckedMalloc(alloc_size, result)) 42 if (!UncheckedMalloc(alloc_size, result))
46 return false; 43 return false;
47 44
48 memset(*result, 0, alloc_size); 45 memset(*result, 0, alloc_size);
49 return true; 46 return true;
50 } 47 }
51 48
52 #endif
53
54 } // namespace base 49 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698