Index: base/allocator/allocator_shim.cc |
diff --git a/base/allocator/allocator_shim.cc b/base/allocator/allocator_shim.cc |
index 1d8229117d77a27035c84a33523b230eea7a3351..239b378216924a6ca5d46d325c1022457b80bef2 100644 |
--- a/base/allocator/allocator_shim.cc |
+++ b/base/allocator/allocator_shim.cc |
@@ -201,6 +201,20 @@ void* realloc(void* ptr, size_t size) __THROW { |
return new_ptr; |
} |
+// This does not call the new handler but let the caller |
+// check whether the allocation succeed. |
+void* allocator_shim_try_malloc(size_t size) __THROW { |
+ switch (allocator) { |
+ case JEMALLOC: |
+ return je_malloc(size); |
+ case WINHEAP: |
+ case WINLFH: |
+ return win_heap_malloc(size); |
+ case TCMALLOC: |
+ return do_malloc(size); |
+ } |
+} |
+ |
// TODO(mbelshe): Implement this for other allocators. |
void malloc_stats(void) __THROW { |
#ifdef ENABLE_DYNAMIC_ALLOCATOR_SWITCHING |