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

Unified Diff: skia/ext/SkMemory_new_handler.cpp

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 11 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 | « skia/BUILD.gn ('k') | skia/ext/benchmarking_canvas.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/SkMemory_new_handler.cpp
diff --git a/skia/ext/SkMemory_new_handler.cpp b/skia/ext/SkMemory_new_handler.cpp
index 015521f313ac83b2797689d048557b495e3f9049..7400c71809b2f601a09845dbd2ea01cb8bee55c2 100644
--- a/skia/ext/SkMemory_new_handler.cpp
+++ b/skia/ext/SkMemory_new_handler.cpp
@@ -53,20 +53,13 @@ void* sk_malloc_throw(size_t size) {
static void* sk_malloc_nothrow(size_t size) {
// TODO(b.kelemen): we should always use UncheckedMalloc but currently it
// doesn't work as intended everywhere.
-#if defined(LIBC_GLIBC) || defined(USE_TCMALLOC) || \
- (defined(OS_MACOSX) && !defined(OS_IOS)) || defined(OS_ANDROID)
+#if defined(OS_IOS)
+ return malloc(size);
+#else
void* result;
// It's the responsibility of the caller to check the return value.
ignore_result(base::UncheckedMalloc(size, &result));
return result;
-#else
- // This is not really thread safe. It only won't collide with itself, but we're totally
- // unprotected from races with other code that calls set_new_handler.
- SkAutoMutexAcquire lock(gSkNewHandlerMutex);
- std::new_handler old_handler = std::set_new_handler(NULL);
- void* p = malloc(size);
- std::set_new_handler(old_handler);
- return p;
#endif
}
@@ -84,17 +77,12 @@ void* sk_calloc_throw(size_t size) {
void* sk_calloc(size_t size) {
// TODO(b.kelemen): we should always use UncheckedCalloc but currently it
// doesn't work as intended everywhere.
-#if defined(LIBC_GLIBC) || defined(USE_TCMALLOC) || \
- (defined(OS_MACOSX) && !defined(OS_IOS)) || defined(OS_ANDROID)
+#if defined(OS_IOS)
+ return calloc(1, size);
+#else
void* result;
// It's the responsibility of the caller to check the return value.
ignore_result(base::UncheckedCalloc(size, 1, &result));
return result;
-#else
- SkAutoMutexAcquire lock(gSkNewHandlerMutex);
- std::new_handler old_handler = std::set_new_handler(NULL);
- void* p = calloc(size, 1);
- std::set_new_handler(old_handler);
- return p;
#endif
}
« no previous file with comments | « skia/BUILD.gn ('k') | skia/ext/benchmarking_canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698