1 #ifndef _MUSL_MALLOC_H 2 #define _MUSL_MALLOC_H 3 4 #include "malloc.h" 5 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 #ifdef HOOK_ENABLE 11 #define MuslMalloc(func) __libc_ ## func 12 #else 13 #define MuslMalloc(func) func 14 #endif 15 16 #ifdef USE_JEMALLOC 17 extern void* je_malloc(size_t size); 18 extern void* je_calloc(size_t count, size_t size); 19 extern void* je_realloc(void* p, size_t newsize); 20 extern void je_free(void* p); 21 #define MuslFunc(func) je_ ## func 22 #else 23 extern void *__libc_malloc(size_t size); 24 extern void __libc_free(void* p); 25 extern void *hook_calloc(size_t, size_t); 26 #define hook_malloc __libc_malloc 27 #define hook_free __libc_free 28 #define hook_realloc __libc_realloc 29 #define MuslFunc(func) hook_ ## func 30 #endif 31 32 void *__libc_mmap(void*, size_t, int, int, int, off_t); 33 int __libc_munmap(void*, size_t); 34 void *__libc_calloc(size_t, size_t); 35 void *__libc_realloc(void *, size_t); 36 void *__libc_valloc(size_t); 37 void *__libc_memalign(size_t, size_t); 38 size_t __libc_malloc_usable_size(void *); 39 int __libc_prctl(int, ...); 40 41 struct mallinfo2 __libc_mallinfo2(void); 42 43 int __libc_malloc_iterate(void* base, size_t size, void (*callback)(void* base, size_t size, void* arg), void* arg); 44 void __libc_malloc_disable(void); 45 void __libc_malloc_enable(void); 46 47 int __libc_malloc_info(int options, FILE* fp); 48 void __libc_malloc_stats_print(void (*write_cb) (void *, const char *), void *cbopaque, const char *opts); 49 50 int __libc_mallopt(int param, int value); 51 ssize_t __libc_malloc_backtrace(void* pointer, uintptr_t* frames, size_t frame_count); 52 53 54 #ifdef __cplusplus 55 } 56 #endif 57 58 #endif 59