summaryrefslogtreecommitdiff
path: root/src/debugallocation.cc
diff options
context:
space:
mode:
authorAliaksey Kandratsenka <alk@tut.by>2014-04-01 21:30:27 -0700
committerAliaksey Kandratsenka <alk@tut.by>2014-04-01 22:07:31 -0700
commit0399af1019240e2d9127a588ddc8e31ff4656df0 (patch)
treed75817c2c2d6fdf6f2e6ef5fb3a39fd9e9ec7b5e /src/debugallocation.cc
parentd77317247e1c8de1ea4e0419318b26f636e64431 (diff)
downloadgperftools-0399af1019240e2d9127a588ddc8e31ff4656df0.tar.gz
added tc_malloc_skip_new_handler
This is port of corresponding chromium change at: https://codereview.chromium.org/55333002/ Basic idea is that sometimes apps that use tc_set_new_mode in order to have C++ out-of-memory handler catch OOMs in malloc, need to invoke usual malloc that returns 0 on OOM. That new API is exactly for that. It'll always return NULL on OOM even if tc_new_mode is set to true.
Diffstat (limited to 'src/debugallocation.cc')
-rw-r--r--src/debugallocation.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/debugallocation.cc b/src/debugallocation.cc
index b7e72cf..4f03d9c 100644
--- a/src/debugallocation.cc
+++ b/src/debugallocation.cc
@@ -1486,3 +1486,9 @@ extern "C" PERFTOOLS_DLL_DECL struct mallinfo tc_mallinfo(void) __THROW {
extern "C" PERFTOOLS_DLL_DECL size_t tc_malloc_size(void* ptr) __THROW {
return MallocExtension::instance()->GetAllocatedSize(ptr);
}
+
+extern "C" PERFTOOLS_DLL_DECL void* tc_malloc_skip_new_handler(size_t size) __THROW {
+ void* result = DebugAllocate(size, MallocBlock::kMallocType);
+ MallocHook::InvokeNewHook(result, size);
+ return result;
+}