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

Unified Diff: base/process/memory_mac.mm

Issue 23455061: Add sk_calloc and sk_calloc_throw to SkMemory_new_handler.cpp. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: throwOnFailure -> throw_on_failure Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process/memory.h ('k') | skia/ext/SkMemory_new_handler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/memory_mac.mm
diff --git a/base/process/memory_mac.mm b/base/process/memory_mac.mm
index 9173a37aa4a5a3fdbe49ddd8e6fd39cbf47ca38b..d1518faaa064b7e001740709bcf58cbbf54a3946 100644
--- a/base/process/memory_mac.mm
+++ b/base/process/memory_mac.mm
@@ -108,7 +108,7 @@ class ThreadLocalBooleanAutoReset {
};
base::LazyInstance<ThreadLocalBoolean>::Leaky
- g_unchecked_malloc = LAZY_INSTANCE_INITIALIZER;
+ g_unchecked_alloc = LAZY_INSTANCE_INITIALIZER;
// NOTE(shess): This is called when the malloc library noticed that the heap
// is fubar. Avoid calls which will re-enter the malloc library.
@@ -120,7 +120,7 @@ void CrMallocErrorBreak() {
// to the OOM killer. The EBADF case comes up because the malloc library
// attempts to log to ASL (syslog) before calling this code, which fails
// accessing a Unix-domain socket because of sandboxing.
- if (errno == ENOMEM || (errno == EBADF && g_unchecked_malloc.Get().Get()))
+ if (errno == ENOMEM || (errno == EBADF && g_unchecked_alloc.Get().Get()))
return;
// A unit test checks this error message, so it needs to be in release builds.
@@ -493,13 +493,24 @@ void* UncheckedMalloc(size_t size) {
if (g_old_malloc) {
#if ARCH_CPU_32_BITS
ScopedClearErrno clear_errno;
- ThreadLocalBooleanAutoReset flag(g_unchecked_malloc.Pointer(), true);
+ ThreadLocalBooleanAutoReset flag(g_unchecked_alloc.Pointer(), true);
#endif // ARCH_CPU_32_BITS
return g_old_malloc(malloc_default_zone(), size);
}
return malloc(size);
}
+void* UncheckedCalloc(size_t num_items, size_t size) {
+ if (g_old_calloc) {
+#if ARCH_CPU_32_BITS
+ ScopedClearErrno clear_errno;
+ ThreadLocalBooleanAutoReset flag(g_unchecked_alloc.Pointer(), true);
+#endif // ARCH_CPU_32_BITS
+ return g_old_calloc(malloc_default_zone(), num_items, size);
+ }
+ return calloc(num_items, size);
+}
+
void EnableTerminationOnOutOfMemory() {
if (g_oom_killer_enabled)
return;
« no previous file with comments | « base/process/memory.h ('k') | skia/ext/SkMemory_new_handler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698