Chromium Code Reviews| Index: base/process/memory_linux.cc |
| diff --git a/base/process/memory_linux.cc b/base/process/memory_linux.cc |
| index 6bed68bd8320346b1ff98a39417e604e0339b020..96b93d61cfa29b070aedc7da4b261052f67631ba 100644 |
| --- a/base/process/memory_linux.cc |
| +++ b/base/process/memory_linux.cc |
| @@ -12,6 +12,16 @@ |
| #include "base/process/internal_linux.h" |
| #include "base/strings/string_number_conversions.h" |
| +#if defined(USE_TCMALLOC) |
| +// Used by UncheckedMalloc. If tcmalloc is linked to the executable |
| +// this will be replaced by a strong symbol that actually implement |
| +// the semantics and don't call new handler in case the allocation fails. |
| +extern "C" __attribute__((weak)) |
| +void* tc_malloc_skip_new_handler_weak(size_t size) { |
| + return malloc(size); |
| +} |
| +#endif |
| + |
| namespace base { |
| size_t g_oom_size = 0U; |
| @@ -182,4 +192,17 @@ bool AdjustOOMScore(ProcessId process, int score) { |
| return false; |
| } |
| +bool UncheckedMalloc(size_t size, void** result) { |
| +#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \ |
| + defined(THREAD_SANITIZER) || defined(LEAK_SANITIZER) || \ |
| + (!defined(LIBC_GLIBC) && !defined(USE_TCMALLOC)) |
| + *result = malloc(size); |
| +#elif defined(LIBC_GLIBC) && !defined(USE_TCMALLOC) |
| + *result = __libc_malloc(size); |
| +#elif defined(USE_TCMALLOC) |
| + *result = tc_malloc_skip_new_handler_weak(size); |
| +#endif |
| + return *result; |
|
jar (doing other things)
2014/02/26 03:59:52
nit: Clearer might be:
return NULL != *result;
|
| +} |
| + |
| } // namespace base |