summaryrefslogtreecommitdiff
path: root/libc/malloc_debug/malloc_debug.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2018-02-05 18:14:55 -0800
committerChristopher Ferris <cferris@google.com>2018-02-07 06:57:14 -0800
commitcae21a9b53a10f0cba79bf6783c4a5af16228fed (patch)
treec60c6622d2b80f9ad4ae5a990b7fb3439f16444b /libc/malloc_debug/malloc_debug.cpp
parentbe6fbae74fc3048647caadd58a9eaad81245e934 (diff)
Add aligned_alloc to libc.
Bug: 72969374 Test: Bionic unit tests pass. Test: Malloc debug unit tests pass. Change-Id: I235985bbc638855d94249c97c98f14ab2924bda0 (cherry picked from commit d69ee59594088c0d92ba9273188ef53ea5e6cd6a)
Diffstat (limited to 'libc/malloc_debug/malloc_debug.cpp')
-rw-r--r--libc/malloc_debug/malloc_debug.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index a2ada2f2e..ecfbd7112 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -77,6 +77,7 @@ void debug_free_malloc_leak_info(uint8_t* info);
size_t debug_malloc_usable_size(void* pointer);
void* debug_malloc(size_t size);
void debug_free(void* pointer);
+void* debug_aligned_alloc(size_t alignment, size_t size);
void* debug_memalign(size_t alignment, size_t bytes);
void* debug_realloc(void* pointer, size_t bytes);
void* debug_calloc(size_t nmemb, size_t bytes);
@@ -669,6 +670,17 @@ int debug_mallopt(int param, int value) {
return g_dispatch->mallopt(param, value);
}
+void* debug_aligned_alloc(size_t alignment, size_t size) {
+ if (DebugCallsDisabled()) {
+ return g_dispatch->aligned_alloc(alignment, size);
+ }
+ if (!powerof2(alignment)) {
+ errno = EINVAL;
+ return nullptr;
+ }
+ return debug_memalign(alignment, size);
+}
+
int debug_posix_memalign(void** memptr, size_t alignment, size_t size) {
if (DebugCallsDisabled()) {
return g_dispatch->posix_memalign(memptr, alignment, size);