From 6f517cd7a1142191fde2201b6c529758e7ff6895 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Fri, 8 Nov 2019 11:28:38 -0800 Subject: [PATCH] Rename iterate to malloc_iterate internally. I have no idea why I used the iterate name internally which is completely unlike every other function name. Change this to match everyone else so that it's now malloc_iterate everywhere. This is probably the last chance to change this before mainline modules begin, so make everything consistent. Test: Compiles, unit tests passes. Change-Id: I56d293377fa0fe1a3dc3dd85d6432f877cc2003c --- libc/bionic/jemalloc.h | 2 +- libc/bionic/malloc_common.cpp | 11 ++++++----- libc/bionic/malloc_common.h | 6 +++--- libc/bionic/malloc_common_dynamic.cpp | 5 +++-- libc/bionic/malloc_heapprofd.cpp | 2 +- libc/bionic/malloc_limit.cpp | 4 ++-- libc/bionic/scudo.h | 2 +- libc/bionic/scudo_wrapper.cpp | 2 +- libc/malloc_debug/exported32.map | 2 +- libc/malloc_debug/exported64.map | 2 +- libc/malloc_debug/malloc_debug.cpp | 8 ++++---- libc/malloc_hooks/exported32.map | 2 +- libc/malloc_hooks/exported64.map | 2 +- libc/malloc_hooks/malloc_hooks.cpp | 4 ++-- libc/private/bionic_malloc_dispatch.h | 2 +- 15 files changed, 29 insertions(+), 27 deletions(-) diff --git a/libc/bionic/jemalloc.h b/libc/bionic/jemalloc.h index ef77c9c99..4ce51c0a8 100644 --- a/libc/bionic/jemalloc.h +++ b/libc/bionic/jemalloc.h @@ -29,7 +29,7 @@ __BEGIN_DECLS void* je_aligned_alloc_wrapper(size_t, size_t); -int je_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*); +int je_malloc_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*); int je_mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) __attribute__((nothrow)); struct mallinfo je_mallinfo(); void je_malloc_disable(); diff --git a/libc/bionic/malloc_common.cpp b/libc/bionic/malloc_common.cpp index 96e614048..a0da3dbff 100644 --- a/libc/bionic/malloc_common.cpp +++ b/libc/bionic/malloc_common.cpp @@ -215,9 +215,9 @@ extern "C" int malloc_iterate(uintptr_t base, size_t size, void (*callback)(uintptr_t base, size_t size, void* arg), void* arg) { auto dispatch_table = GetDispatchTable(); if (__predict_false(dispatch_table != nullptr)) { - return dispatch_table->iterate(base, size, callback, arg); + return dispatch_table->malloc_iterate(base, size, callback, arg); } - return Malloc(iterate)(base, size, callback, arg); + return Malloc(malloc_iterate)(base, size, callback, arg); } // Disable calls to malloc so malloc_iterate gets a consistent view of @@ -247,9 +247,10 @@ extern "C" ssize_t malloc_backtrace(void*, uintptr_t*, size_t) { #if __has_feature(hwaddress_sanitizer) // FIXME: implement these in HWASan allocator. -extern "C" int __sanitizer_iterate(uintptr_t base __unused, size_t size __unused, - void (*callback)(uintptr_t base, size_t size, void* arg) __unused, - void* arg __unused) { +extern "C" int __sanitizer_malloc_iterate(uintptr_t base __unused, size_t size __unused, + void (*callback)(uintptr_t base, size_t size, void* arg) + __unused, + void* arg __unused) { return 0; } diff --git a/libc/bionic/malloc_common.h b/libc/bionic/malloc_common.h index 2176e634d..89dccc31a 100644 --- a/libc/bionic/malloc_common.h +++ b/libc/bionic/malloc_common.h @@ -42,9 +42,9 @@ __BEGIN_DECLS // FIXME: implement these in HWASan allocator. -int __sanitizer_iterate(uintptr_t base, size_t size, - void (*callback)(uintptr_t base, size_t size, void* arg), - void* arg); +int __sanitizer_malloc_iterate(uintptr_t base, size_t size, + void (*callback)(uintptr_t base, size_t size, void* arg), + void* arg); void __sanitizer_malloc_disable(); void __sanitizer_malloc_enable(); int __sanitizer_malloc_info(int options, FILE* fp); diff --git a/libc/bionic/malloc_common_dynamic.cpp b/libc/bionic/malloc_common_dynamic.cpp index 9ad79a0d0..0ac3f62e6 100644 --- a/libc/bionic/malloc_common_dynamic.cpp +++ b/libc/bionic/malloc_common_dynamic.cpp @@ -95,7 +95,7 @@ static constexpr MallocDispatch __libc_malloc_default_dispatch #if defined(HAVE_DEPRECATED_MALLOC_FUNCS) Malloc(valloc), #endif - Malloc(iterate), + Malloc(malloc_iterate), Malloc(malloc_disable), Malloc(malloc_enable), Malloc(mallopt), @@ -184,7 +184,8 @@ static bool InitMallocFunctions(void* impl_handler, MallocDispatch* table, const if (!InitMallocFunction(impl_handler, &table->realloc, prefix, "realloc")) { return false; } - if (!InitMallocFunction(impl_handler, &table->iterate, prefix, "iterate")) { + if (!InitMallocFunction(impl_handler, &table->malloc_iterate, prefix, + "malloc_iterate")) { return false; } if (!InitMallocFunction(impl_handler, &table->malloc_disable, prefix, diff --git a/libc/bionic/malloc_heapprofd.cpp b/libc/bionic/malloc_heapprofd.cpp index 62249fb1d..586022200 100644 --- a/libc/bionic/malloc_heapprofd.cpp +++ b/libc/bionic/malloc_heapprofd.cpp @@ -104,7 +104,7 @@ static constexpr MallocDispatch __heapprofd_init_dispatch #if defined(HAVE_DEPRECATED_MALLOC_FUNCS) Malloc(valloc), #endif - Malloc(iterate), + Malloc(malloc_iterate), Malloc(malloc_disable), Malloc(malloc_enable), Malloc(mallopt), diff --git a/libc/bionic/malloc_limit.cpp b/libc/bionic/malloc_limit.cpp index 6a67cae95..d8c0ebe54 100644 --- a/libc/bionic/malloc_limit.cpp +++ b/libc/bionic/malloc_limit.cpp @@ -350,9 +350,9 @@ static struct mallinfo LimitMallinfo() { static int LimitIterate(uintptr_t base, size_t size, void (*callback)(uintptr_t, size_t, void*), void* arg) { auto dispatch_table = GetDefaultDispatchTable(); if (__predict_false(dispatch_table != nullptr)) { - return dispatch_table->iterate(base, size, callback, arg); + return dispatch_table->malloc_iterate(base, size, callback, arg); } - return Malloc(iterate)(base, size, callback, arg); + return Malloc(malloc_iterate)(base, size, callback, arg); } static void LimitMallocDisable() { diff --git a/libc/bionic/scudo.h b/libc/bionic/scudo.h index d9933c4d0..a80d75418 100644 --- a/libc/bionic/scudo.h +++ b/libc/bionic/scudo.h @@ -52,7 +52,7 @@ void* scudo_pvalloc(size_t); void* scudo_valloc(size_t); #endif -int scudo_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*); +int scudo_malloc_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*); void scudo_malloc_disable(); void scudo_malloc_enable(); diff --git a/libc/bionic/scudo_wrapper.cpp b/libc/bionic/scudo_wrapper.cpp index e17f20ba5..debd8d996 100644 --- a/libc/bionic/scudo_wrapper.cpp +++ b/libc/bionic/scudo_wrapper.cpp @@ -48,7 +48,7 @@ int scudo_malloc_info(int /*options*/, FILE* /*fp*/) { return -1; } -int scudo_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*) { +int scudo_malloc_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*) { return 0; } diff --git a/libc/malloc_debug/exported32.map b/libc/malloc_debug/exported32.map index 8ed37faa2..f75d173df 100644 --- a/libc/malloc_debug/exported32.map +++ b/libc/malloc_debug/exported32.map @@ -8,13 +8,13 @@ LIBC_MALLOC_DEBUG { debug_free_malloc_leak_info; debug_get_malloc_leak_info; debug_initialize; - debug_iterate; debug_mallinfo; debug_malloc; debug_malloc_backtrace; debug_malloc_disable; debug_malloc_enable; debug_malloc_info; + debug_malloc_iterate; debug_malloc_usable_size; debug_mallopt; debug_memalign; diff --git a/libc/malloc_debug/exported64.map b/libc/malloc_debug/exported64.map index cdff88ba1..6dea58c42 100644 --- a/libc/malloc_debug/exported64.map +++ b/libc/malloc_debug/exported64.map @@ -8,13 +8,13 @@ LIBC_MALLOC_DEBUG { debug_free_malloc_leak_info; debug_get_malloc_leak_info; debug_initialize; - debug_iterate; debug_mallinfo; debug_malloc; debug_malloc_backtrace; debug_malloc_disable; debug_malloc_enable; debug_malloc_info; + debug_malloc_iterate; debug_malloc_usable_size; debug_mallopt; debug_memalign; diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp index 3c0e630cf..c0765a983 100644 --- a/libc/malloc_debug/malloc_debug.cpp +++ b/libc/malloc_debug/malloc_debug.cpp @@ -91,8 +91,8 @@ struct mallinfo debug_mallinfo(); int debug_mallopt(int param, int value); int debug_malloc_info(int options, FILE* fp); int debug_posix_memalign(void** memptr, size_t alignment, size_t size); -int debug_iterate(uintptr_t base, size_t size, - void (*callback)(uintptr_t base, size_t size, void* arg), void* arg); +int debug_malloc_iterate(uintptr_t base, size_t size, + void (*callback)(uintptr_t base, size_t size, void* arg), void* arg); void debug_malloc_disable(); void debug_malloc_enable(); @@ -841,7 +841,7 @@ int debug_posix_memalign(void** memptr, size_t alignment, size_t size) { return (*memptr != nullptr) ? 0 : ENOMEM; } -int debug_iterate(uintptr_t base, size_t size, void (*callback)(uintptr_t, size_t, void*), +int debug_malloc_iterate(uintptr_t base, size_t size, void (*callback)(uintptr_t, size_t, void*), void* arg) { ScopedConcurrentLock lock; if (g_debug->TrackPointers()) { @@ -854,7 +854,7 @@ int debug_iterate(uintptr_t base, size_t size, void (*callback)(uintptr_t, size_ // An option that adds a header will add pointer tracking, so no need to // check if headers are enabled. - return g_dispatch->iterate(base, size, callback, arg); + return g_dispatch->malloc_iterate(base, size, callback, arg); } void debug_malloc_disable() { diff --git a/libc/malloc_hooks/exported32.map b/libc/malloc_hooks/exported32.map index 293d9ac15..2b028062b 100644 --- a/libc/malloc_hooks/exported32.map +++ b/libc/malloc_hooks/exported32.map @@ -7,13 +7,13 @@ LIBC_MALLOC_HOOKS { hooks_free_malloc_leak_info; hooks_get_malloc_leak_info; hooks_initialize; - hooks_iterate; hooks_mallinfo; hooks_malloc; hooks_malloc_backtrace; hooks_malloc_disable; hooks_malloc_enable; hooks_malloc_info; + hooks_malloc_iterate; hooks_malloc_usable_size; hooks_mallopt; hooks_memalign; diff --git a/libc/malloc_hooks/exported64.map b/libc/malloc_hooks/exported64.map index 340106b2e..59ec1f01f 100644 --- a/libc/malloc_hooks/exported64.map +++ b/libc/malloc_hooks/exported64.map @@ -7,13 +7,13 @@ LIBC_MALLOC_HOOKS { hooks_free_malloc_leak_info; hooks_get_malloc_leak_info; hooks_initialize; - hooks_iterate; hooks_mallinfo; hooks_malloc; hooks_malloc_backtrace; hooks_malloc_disable; hooks_malloc_enable; hooks_malloc_info; + hooks_malloc_iterate; hooks_malloc_usable_size; hooks_mallopt; hooks_memalign; diff --git a/libc/malloc_hooks/malloc_hooks.cpp b/libc/malloc_hooks/malloc_hooks.cpp index b1c1d5060..1ba869698 100644 --- a/libc/malloc_hooks/malloc_hooks.cpp +++ b/libc/malloc_hooks/malloc_hooks.cpp @@ -67,7 +67,7 @@ void* hooks_calloc(size_t nmemb, size_t bytes); struct mallinfo hooks_mallinfo(); int hooks_mallopt(int param, int value); int hooks_posix_memalign(void** memptr, size_t alignment, size_t size); -int hooks_iterate(uintptr_t base, size_t size, +int hooks_malloc_iterate(uintptr_t base, size_t size, void (*callback)(uintptr_t base, size_t size, void* arg), void* arg); void hooks_malloc_disable(); void hooks_malloc_enable(); @@ -209,7 +209,7 @@ int hooks_posix_memalign(void** memptr, size_t alignment, size_t size) { return g_dispatch->posix_memalign(memptr, alignment, size); } -int hooks_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*) { +int hooks_malloc_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*) { return 0; } diff --git a/libc/private/bionic_malloc_dispatch.h b/libc/private/bionic_malloc_dispatch.h index aea3a1c09..52d857317 100644 --- a/libc/private/bionic_malloc_dispatch.h +++ b/libc/private/bionic_malloc_dispatch.h @@ -70,7 +70,7 @@ struct MallocDispatch { #if defined(HAVE_DEPRECATED_MALLOC_FUNCS) MallocValloc valloc; #endif - MallocIterate iterate; + MallocIterate malloc_iterate; MallocMallocDisable malloc_disable; MallocMallocEnable malloc_enable; MallocMallopt mallopt;