summaryrefslogtreecommitdiff
path: root/libc/malloc_hooks/malloc_hooks.cpp
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-03-10 00:05:58 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-03-10 00:05:58 +0000
commit51d8111881f23719bbb909ed57bb43c8277fd97e (patch)
treeee9008a0d61116a2fa184056d4268241940eee7a /libc/malloc_hooks/malloc_hooks.cpp
parent1257f386d3ab81a2ab05e0451663ecb0658b67aa (diff)
parent4e2b6a9793b41cbdc888a00d07bf1bc69ad9f366 (diff)
Snap for 5364434 from 4e2b6a9793b41cbdc888a00d07bf1bc69ad9f366 to qt-release
Change-Id: I7fc94086c894fb41b97d959dfe6c04c7e959c282
Diffstat (limited to 'libc/malloc_hooks/malloc_hooks.cpp')
-rw-r--r--libc/malloc_hooks/malloc_hooks.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/libc/malloc_hooks/malloc_hooks.cpp b/libc/malloc_hooks/malloc_hooks.cpp
index 715a6295b..07b668f08 100644
--- a/libc/malloc_hooks/malloc_hooks.cpp
+++ b/libc/malloc_hooks/malloc_hooks.cpp
@@ -29,6 +29,7 @@
#include <errno.h>
#include <malloc.h>
#include <stdint.h>
+#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#include <unistd.h>
@@ -57,6 +58,7 @@ ssize_t hooks_malloc_backtrace(void* pointer, uintptr_t* frames, size_t frame_co
void hooks_free_malloc_leak_info(uint8_t* info);
size_t hooks_malloc_usable_size(void* pointer);
void* hooks_malloc(size_t size);
+int hooks_malloc_info(int options, FILE* fp);
void hooks_free(void* pointer);
void* hooks_memalign(size_t alignment, size_t bytes);
void* hooks_aligned_alloc(size_t alignment, size_t bytes);
@@ -174,6 +176,10 @@ int hooks_mallopt(int param, int value) {
return g_dispatch->mallopt(param, value);
}
+int hooks_malloc_info(int options, FILE* fp) {
+ return g_dispatch->malloc_info(options, fp);
+}
+
void* hooks_aligned_alloc(size_t alignment, size_t size) {
if (__memalign_hook != nullptr && __memalign_hook != default_memalign_hook) {
if (!powerof2(alignment) || (size % alignment) != 0) {
@@ -191,7 +197,7 @@ void* hooks_aligned_alloc(size_t alignment, size_t size) {
int hooks_posix_memalign(void** memptr, size_t alignment, size_t size) {
if (__memalign_hook != nullptr && __memalign_hook != default_memalign_hook) {
- if (!powerof2(alignment)) {
+ if (alignment < sizeof(void*) || !powerof2(alignment)) {
return EINVAL;
}
*memptr = __memalign_hook(alignment, size, __builtin_return_address(0));