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

Side by Side Diff: base/allocator/generic_allocators.cc

Issue 774683003: Remove tcmalloc when not being used. Restore shim on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove tcmalloc from Windows build. Call new_handler on any allocation failure. Limit to 2Gb. Add … Created 5 years, 11 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 // When possible, we implement allocator functions on top of the basic 5 // When possible, we implement allocator functions on top of the basic
6 // low-level functions malloc() and free(). This way, including a new 6 // low-level functions malloc() and free(). This way, including a new
7 // allocator is as simple as providing just a small interface. 7 // allocator is as simple as providing just a small interface.
8 // 8 //
9 // As such, this file should not contain any allocator-specific code. 9 // As such, this file should not contain any allocator-specific code.
10 10
11 // Implement a C++ style allocation, which always calls the new_handler 11 // Implement a C++ style allocation, which always calls the new_handler
12 // on failure. 12 // on failure.
13 inline void* generic_cpp_alloc(size_t size, bool nothrow) { 13 inline void* generic_cpp_alloc(size_t size, bool nothrow) {
14 void* ptr; 14 void* ptr;
15 for (;;) { 15 for (;;) {
16 ptr = malloc(size); 16 ptr = malloc(size);
17 if (ptr) 17 if (ptr)
18 return ptr; 18 return ptr;
19 if (!call_new_handler(nothrow)) 19 if (!call_new_handler(nothrow, size))
20 break; 20 break;
21 } 21 }
22 return ptr; 22 return ptr;
23 } 23 }
24 24
25 extern "C++" { 25 extern "C++" {
26 26
27 void* operator new(size_t size) { 27 void* operator new(size_t size) {
28 return generic_cpp_alloc(size, false); 28 return generic_cpp_alloc(size, false);
29 } 29 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 void* _calloc_dbg(size_t n, size_t size, int, const char*, int) { 168 void* _calloc_dbg(size_t n, size_t size, int, const char*, int) {
169 return calloc(n, size); 169 return calloc(n, size);
170 } 170 }
171 #endif // NDEBUG 171 #endif // NDEBUG
172 172
173 #endif // WIN32 173 #endif // WIN32
174 174
175 } // extern C 175 } // extern C
176 176
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698