| 2976 | } |
| 2977 | |
| 2978 | JEMALLOC_EXPORT void JEMALLOC_NOTHROW |
| 2979 | je_sdallocx(void *ptr, size_t size, int flags) { |
| 2980 | assert(ptr != NULL); |
| 2981 | assert(malloc_initialized() || IS_INITIALIZER); |
| 2982 | |
| 2983 | LOG("core.sdallocx.entry", "ptr: %p, size: %zu, flags: %d", ptr, |
| 2984 | size, flags); |
| 2985 | |
| 2986 | tsd_t *tsd = tsd_fetch(); |
| 2987 | bool fast = tsd_fast(tsd); |
| 2988 | size_t usize = inallocx(tsd_tsdn(tsd), size, flags); |
| 2989 | assert(usize == isalloc(tsd_tsdn(tsd), ptr)); |
| 2990 | check_entry_exit_locking(tsd_tsdn(tsd)); |
| 2991 | |
| 2992 | tcache_t *tcache; |
| 2993 | if (unlikely((flags & MALLOCX_TCACHE_MASK) != 0)) { |
| 2994 | /* Not allowed to be reentrant and specify a custom tcache. */ |
| 2995 | assert(tsd_reentrancy_level_get(tsd) == 0); |
| 2996 | if ((flags & MALLOCX_TCACHE_MASK) == MALLOCX_TCACHE_NONE) { |
| 2997 | tcache = NULL; |
| 2998 | } else { |
| 2999 | tcache = tcaches_get(tsd, MALLOCX_TCACHE_GET(flags)); |
| 3000 | } |
| 3001 | } else { |
| 3002 | if (likely(fast)) { |
| 3003 | tcache = tsd_tcachep_get(tsd); |
| 3004 | assert(tcache == tcache_get(tsd)); |
| 3005 | } else { |
| 3006 | if (likely(tsd_reentrancy_level_get(tsd) == 0)) { |
| 3007 | tcache = tcache_get(tsd); |
| 3008 | } else { |
| 3009 | tcache = NULL; |
| 3010 | } |
| 3011 | } |
| 3012 | } |
| 3013 | |
| 3014 | UTRACE(ptr, 0, 0); |
| 3015 | if (likely(fast)) { |
| 3016 | tsd_assert_fast(tsd); |
| 3017 | isfree(tsd, ptr, usize, tcache, false); |
| 3018 | } else { |
| 3019 | isfree(tsd, ptr, usize, tcache, true); |
| 3020 | } |
| 3021 | check_entry_exit_locking(tsd_tsdn(tsd)); |
| 3022 | |
| 3023 | LOG("core.sdallocx.exit", ""); |
| 3024 | } |
| 3025 | |
| 3026 | JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW |
| 3027 | JEMALLOC_ATTR(pure) |
no test coverage detected