1 #ifndef _MALLOC_H 2 #define _MALLOC_H 3 4 #include <stdio.h> 5 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 #define __NEED_size_t 11 #define __NEED_ssize_t 12 #define __NEED_uintptr_t 13 14 #include <bits/alltypes.h> 15 16 void *malloc (size_t); 17 void *calloc (size_t, size_t); 18 void *realloc (void *, size_t); 19 void free (void *); 20 void *valloc (size_t); 21 void *memalign(size_t, size_t); 22 23 size_t malloc_usable_size(void *); 24 25 #define __MALLINFO_BODY \ 26 size_t arena; \ 27 size_t ordblks; \ 28 size_t smblks; \ 29 size_t hblks; \ 30 size_t hblkhd; \ 31 size_t usmblks; \ 32 size_t fsmblks; \ 33 size_t uordblks; \ 34 size_t fordblks; \ 35 size_t keepcost; 36 37 struct mallinfo { __MALLINFO_BODY }; 38 39 struct mallinfo mallinfo(void); 40 41 struct mallinfo2 { __MALLINFO_BODY }; 42 43 struct mallinfo2 mallinfo2(void); 44 45 int malloc_iterate(void* base, size_t size, void (*callback)(void* base, size_t size, void* arg), void* arg); 46 void malloc_disable(void); 47 void malloc_enable(void); 48 49 int malloc_info(int options, FILE* fp); 50 void malloc_stats_print(void (*write_cb) (void *, const char *), void *cbopaque, const char *opts); 51 52 53 #define M_SET_THREAD_CACHE (-1001) 54 #define M_THREAD_CACHE_ENABLE 1 55 #define M_THREAD_CACHE_DISABLE 0 56 57 #define M_FLUSH_THREAD_CACHE (-1002) 58 59 #define M_DELAYED_FREE (-1003) 60 #define M_DELAYED_FREE_ENABLE 1 61 #define M_DELAYED_FREE_DISABLE 0 62 63 #define M_OHOS_CONFIG (-1004) 64 #define M_DISABLE_OPT_TCACHE 100 65 #define M_ENABLE_OPT_TCACHE 101 66 #define M_TCACHE_PERFORMANCE_MODE 102 67 #define M_TCACHE_NORMAL_MODE 103 68 69 #define M_SET_SECURITY_LEVEL (-1005) 70 #define M_SECURITY_LEVEL_LOW 10 71 #define M_SECURITY_LEVEL_MID 11 72 #define M_SECURITY_LEVEL_HIGH 12 73 74 #define M_ENABLE_CHECK_DOUBLE_FREE_DEFAULT (-1006) 75 #define M_CHECK_DOUBLE_FREE_DEFAULT_ENABLE 1 76 #define M_CHECK_DOUBLE_FREE_DEFAULT_DISABLE 0 77 78 #define M_ENABLE_CHECK_DOUBLE_FREE_REDZONE (-1007) 79 #define M_CHECK_DOUBLE_FREE_REDZONE_ENABLE 1 80 #define M_CHECK_DOUBLE_FREE_REDZONE_DISABLE 0 81 82 #define M_ENABLE_RANDOM_ALLOCATION (-1008) 83 #define M_RANDOM_ALLOCATION_ENABLE 1 84 #define M_RANDOM_ALLOCATION_DISABLE 0 85 86 #define M_ENABLE_CHECK_USE_AFTER_FREE (-1009) 87 #define M_CHECK_USE_AFTER_FREE_ENABLE 1 88 #define M_CHECK_USE_AFTER_FREE_DISABLE 0 89 90 #define M_ENABLE_CHECK_OVERFLOW_SLAB (-1010) 91 #define M_CHECK_OVERFLOW_SLAB_ENABLE 1 92 #define M_CHECK_OVERFLOW_SLAB_DISABLE 0 93 94 #define M_ENABLE_CHECK_OVERFLOW_LARGE (-1011) 95 #define M_CHECK_OVERFLOW_LARGE_ENABLE 1 96 #define M_CHECK_OVERFLOW_LARGE_DISABLE 0 97 98 #define M_ENABLE_QUARANTINE_DEFAULT (-1012) 99 #define M_QUARANTINE_ENABLE 1 100 #define M_QUARANTINE_DISABLE 0 101 102 #define M_SET_QUARANTINE_SIZE (-1013) 103 104 #define M_SET_QUARANTINE_MAX_BLOCK_SIZE (-1014) 105 106 int mallopt(int param, int value); 107 ssize_t malloc_backtrace(void* pointer, uintptr_t* frames, size_t frame_count); 108 109 #ifdef __cplusplus 110 } 111 #endif 112 113 #endif 114