| 2917 | } |
| 2918 | |
| 2919 | JEMALLOC_EXPORT void JEMALLOC_NOTHROW |
| 2920 | je_dallocx(void *ptr, int flags) { |
| 2921 | LOG("core.dallocx.entry", "ptr: %p, flags: %d", ptr, flags); |
| 2922 | |
| 2923 | assert(ptr != NULL); |
| 2924 | assert(malloc_initialized() || IS_INITIALIZER); |
| 2925 | |
| 2926 | tsd_t *tsd = tsd_fetch(); |
| 2927 | bool fast = tsd_fast(tsd); |
| 2928 | check_entry_exit_locking(tsd_tsdn(tsd)); |
| 2929 | |
| 2930 | tcache_t *tcache; |
| 2931 | if (unlikely((flags & MALLOCX_TCACHE_MASK) != 0)) { |
| 2932 | /* Not allowed to be reentrant and specify a custom tcache. */ |
| 2933 | assert(tsd_reentrancy_level_get(tsd) == 0); |
| 2934 | if ((flags & MALLOCX_TCACHE_MASK) == MALLOCX_TCACHE_NONE) { |
| 2935 | tcache = NULL; |
| 2936 | } else { |
| 2937 | tcache = tcaches_get(tsd, MALLOCX_TCACHE_GET(flags)); |
| 2938 | } |
| 2939 | } else { |
| 2940 | if (likely(fast)) { |
| 2941 | tcache = tsd_tcachep_get(tsd); |
| 2942 | assert(tcache == tcache_get(tsd)); |
| 2943 | } else { |
| 2944 | if (likely(tsd_reentrancy_level_get(tsd) == 0)) { |
| 2945 | tcache = tcache_get(tsd); |
| 2946 | } else { |
| 2947 | tcache = NULL; |
| 2948 | } |
| 2949 | } |
| 2950 | } |
| 2951 | |
| 2952 | UTRACE(ptr, 0, 0); |
| 2953 | if (likely(fast)) { |
| 2954 | tsd_assert_fast(tsd); |
| 2955 | ifree(tsd, ptr, tcache, false); |
| 2956 | } else { |
| 2957 | ifree(tsd, ptr, tcache, true); |
| 2958 | } |
| 2959 | check_entry_exit_locking(tsd_tsdn(tsd)); |
| 2960 | |
| 2961 | LOG("core.dallocx.exit", ""); |
| 2962 | } |
| 2963 | |
| 2964 | JEMALLOC_ALWAYS_INLINE size_t |
| 2965 | inallocx(tsdn_t *tsdn, size_t size, int flags) { |
nothing calls this directly
no test coverage detected