aboutsummaryrefslogtreecommitdiff
path: root/www/chromium/files/patch-base_allocator_allocator__shim__default__dispatch__to__glibc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'www/chromium/files/patch-base_allocator_allocator__shim__default__dispatch__to__glibc.cc')
-rw-r--r--www/chromium/files/patch-base_allocator_allocator__shim__default__dispatch__to__glibc.cc70
1 files changed, 70 insertions, 0 deletions
diff --git a/www/chromium/files/patch-base_allocator_allocator__shim__default__dispatch__to__glibc.cc b/www/chromium/files/patch-base_allocator_allocator__shim__default__dispatch__to__glibc.cc
new file mode 100644
index 000000000000..7ffd924176c0
--- /dev/null
+++ b/www/chromium/files/patch-base_allocator_allocator__shim__default__dispatch__to__glibc.cc
@@ -0,0 +1,70 @@
+--- base/allocator/allocator_shim_default_dispatch_to_glibc.cc.orig 2016-08-03 22:02:10.000000000 +0300
++++ base/allocator/allocator_shim_default_dispatch_to_glibc.cc 2016-09-21 22:14:12.220734000 +0300
+@@ -3,17 +3,28 @@
+ // found in the LICENSE file.
+
+ #include "base/allocator/allocator_shim.h"
++#include <stdio.h>
++#include <stdlib.h>
++#include <malloc_np.h>
+
+ // This translation unit defines a default dispatch for the allocator shim which
+ // routes allocations to libc functions.
+-// The code here is strongly inspired from tcmalloc's libc_override_glibc.h.
++// The code here is strongly inspired from tcmalloc's override_glibc.h.
+
+ extern "C" {
+-void* __libc_malloc(size_t size);
+-void* __libc_calloc(size_t n, size_t size);
+-void* __libc_realloc(void* address, size_t size);
+-void* __libc_memalign(size_t alignment, size_t size);
+-void __libc_free(void* ptr);
++void* __malloc(size_t size);
++void* __calloc(size_t n, size_t size);
++void* __realloc(void* address, size_t size);
++void* __memalign(size_t alignment, size_t size) {
++ void *ret;
++ if (__posix_memalign(&ret, alignment, size) != 0) {
++ return nullptr;
++ } else {
++ return ret;
++ }
++}
++int __posix_memalign(void **ptr, size_t alignment, size_t size);
++void __free(void* ptr);
+ } // extern "C"
+
+ namespace {
+@@ -21,23 +32,27 @@
+ using base::allocator::AllocatorDispatch;
+
+ void* GlibcMalloc(const AllocatorDispatch*, size_t size) {
+- return __libc_malloc(size);
++ return __malloc(size);
+ }
+
+ void* GlibcCalloc(const AllocatorDispatch*, size_t n, size_t size) {
+- return __libc_calloc(n, size);
++ return __calloc(n, size);
+ }
+
+ void* GlibcRealloc(const AllocatorDispatch*, void* address, size_t size) {
+- return __libc_realloc(address, size);
++ return __realloc(address, size);
+ }
+
+ void* GlibcMemalign(const AllocatorDispatch*, size_t alignment, size_t size) {
+- return __libc_memalign(alignment, size);
++ return __memalign(alignment, size);
+ }
+
++/* int GlibcPosixMemalign(const AllocatorDispatch*, void** ptr, size_t alignment, size_t size) { */
++/* return __posix_memalign(ptr, alignment, size); */
++/* } */
++
+ void GlibcFree(const AllocatorDispatch*, void* address) {
+- __libc_free(address);
++ __free(address);
+ }
+
+ } // namespace