| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/allocator/allocator_shim.h" | 5 #include "base/allocator/allocator_shim.h" |
| 6 | 6 |
| 7 #include <config.h> | 7 #include <config.h> |
| 8 #include "base/allocator/allocator_extension_thunks.h" | 8 #include "base/allocator/allocator_extension_thunks.h" |
| 9 #include "base/profiler/alternate_timer.h" | 9 #include "base/profiler/alternate_timer.h" |
| 10 #include "base/sysinfo.h" | 10 #include "base/sysinfo.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 // the requested new size is zero, realloc should free the ptr and return | 194 // the requested new size is zero, realloc should free the ptr and return |
| 195 // NULL. | 195 // NULL. |
| 196 if (new_ptr || !size) | 196 if (new_ptr || !size) |
| 197 return new_ptr; | 197 return new_ptr; |
| 198 if (!new_mode || !call_new_handler(true)) | 198 if (!new_mode || !call_new_handler(true)) |
| 199 break; | 199 break; |
| 200 } | 200 } |
| 201 return new_ptr; | 201 return new_ptr; |
| 202 } | 202 } |
| 203 | 203 |
| 204 // This does not call the new handler but let the caller |
| 205 // check whether the allocation succeed. |
| 206 void* allocator_shim_try_malloc(size_t size) __THROW { |
| 207 switch (allocator) { |
| 208 case JEMALLOC: |
| 209 return je_malloc(size); |
| 210 case WINHEAP: |
| 211 case WINLFH: |
| 212 return win_heap_malloc(size); |
| 213 case TCMALLOC: |
| 214 return do_malloc(size); |
| 215 } |
| 216 } |
| 217 |
| 204 // TODO(mbelshe): Implement this for other allocators. | 218 // TODO(mbelshe): Implement this for other allocators. |
| 205 void malloc_stats(void) __THROW { | 219 void malloc_stats(void) __THROW { |
| 206 #ifdef ENABLE_DYNAMIC_ALLOCATOR_SWITCHING | 220 #ifdef ENABLE_DYNAMIC_ALLOCATOR_SWITCHING |
| 207 switch (allocator) { | 221 switch (allocator) { |
| 208 case JEMALLOC: | 222 case JEMALLOC: |
| 209 // No stats. | 223 // No stats. |
| 210 return; | 224 return; |
| 211 case WINHEAP: | 225 case WINHEAP: |
| 212 case WINLFH: | 226 case WINLFH: |
| 213 // No stats. | 227 // No stats. |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 void TCMallocDoFreeForTest(void* ptr) { | 451 void TCMallocDoFreeForTest(void* ptr) { |
| 438 do_free(ptr); | 452 do_free(ptr); |
| 439 } | 453 } |
| 440 | 454 |
| 441 size_t ExcludeSpaceForMarkForTest(size_t size) { | 455 size_t ExcludeSpaceForMarkForTest(size_t size) { |
| 442 return ExcludeSpaceForMark(size); | 456 return ExcludeSpaceForMark(size); |
| 443 } | 457 } |
| 444 | 458 |
| 445 } // namespace allocator. | 459 } // namespace allocator. |
| 446 } // namespace base. | 460 } // namespace base. |
| OLD | NEW |