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

Side by Side Diff: third_party/tcmalloc/allocator_shim.cc

Issue 194040: Fix realloc to not call the new_handler (which is for failures)... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 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 #include <config.h> 5 #include <config.h>
6 6
7 // When defined, different heap allocators can be used via an environment 7 // When defined, different heap allocators can be used via an environment
8 // variable set before running the program. This may reduce the amount 8 // variable set before running the program. This may reduce the amount
9 // of inlining that we get with malloc/free/etc. Disabling makes it 9 // of inlining that we get with malloc/free/etc. Disabling makes it
10 // so that only tcmalloc can be used. 10 // so that only tcmalloc can be used.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 break; 153 break;
154 case TCMALLOC: 154 case TCMALLOC:
155 default: 155 default:
156 new_ptr = do_realloc(ptr, size); 156 new_ptr = do_realloc(ptr, size);
157 break; 157 break;
158 } 158 }
159 #else 159 #else
160 // TCMalloc case. 160 // TCMalloc case.
161 new_ptr = do_realloc(ptr, size); 161 new_ptr = do_realloc(ptr, size);
162 #endif 162 #endif
163 if (new_ptr) 163
164 // Subtle warning: NULL return does not alwas indicate out-of-memory. If
165 // the requested new size is zero, realloc should free the ptr and return
166 // NULL.
167 if (new_ptr || !size)
164 return new_ptr; 168 return new_ptr;
165 if (!new_mode || !call_new_handler(true)) 169 if (!new_mode || !call_new_handler(true))
166 break; 170 break;
167 } 171 }
168 return new_ptr; 172 return new_ptr;
169 } 173 }
170 174
171 // TODO(mbelshe): Implement this for other allocators. 175 // TODO(mbelshe): Implement this for other allocators.
172 void malloc_stats(void) __THROW { 176 void malloc_stats(void) __THROW {
173 #ifdef ENABLE_DYNAMIC_ALLOCATOR_SWITCHING 177 #ifdef ENABLE_DYNAMIC_ALLOCATOR_SWITCHING
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // to test whether the CRT has been initialized. Once we've ripped out 251 // to test whether the CRT has been initialized. Once we've ripped out
248 // the allocators from libcmt, we need to provide this definition so that 252 // the allocators from libcmt, we need to provide this definition so that
249 // the rest of the CRT is still usable. 253 // the rest of the CRT is still usable.
250 extern "C" void* _crtheap = reinterpret_cast<void*>(1); 254 extern "C" void* _crtheap = reinterpret_cast<void*>(1);
251 255
252 #endif // WIN32 256 #endif // WIN32
253 257
254 #include "generic_allocators.cc" 258 #include "generic_allocators.cc"
255 259
256 } // extern C 260 } // extern C
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698