| Index: base/process/memory_linux.cc
|
| diff --git a/base/process/memory_linux.cc b/base/process/memory_linux.cc
|
| index a40c2707edb34dc8ba27937cb5362ca3323022b4..e1d452b67fa8ed769485be714d97e33bc0730d19 100644
|
| --- a/base/process/memory_linux.cc
|
| +++ b/base/process/memory_linux.cc
|
| @@ -12,6 +12,22 @@
|
| #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, visibility("default")))
|
| +void* tc_malloc_skip_new_handler_weak(size_t size);
|
| +
|
| +void* tc_malloc_skip_new_handler_weak(size_t size) {
|
| + return malloc(size);
|
| +}
|
| +
|
| +}
|
| +#endif
|
| +
|
| namespace base {
|
|
|
| size_t g_oom_size = 0U;
|
| @@ -182,4 +198,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 != NULL;
|
| +}
|
| +
|
| } // namespace base
|
|
|