MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / sdallocx_default

Function sdallocx_default

deps/jemalloc/src/jemalloc.c:3547–3591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3545}
3546
3547JEMALLOC_NOINLINE void
3548sdallocx_default(void *ptr, size_t size, int flags) {
3549 assert(ptr != NULL);
3550 assert(malloc_initialized() || IS_INITIALIZER);
3551
3552 tsd_t *tsd = tsd_fetch();
3553 bool fast = tsd_fast(tsd);
3554 size_t usize = inallocx(tsd_tsdn(tsd), size, flags);
3555 assert(usize == isalloc(tsd_tsdn(tsd), ptr));
3556 check_entry_exit_locking(tsd_tsdn(tsd));
3557
3558 tcache_t *tcache;
3559 if (unlikely((flags & MALLOCX_TCACHE_MASK) != 0)) {
3560 /* Not allowed to be reentrant and specify a custom tcache. */
3561 assert(tsd_reentrancy_level_get(tsd) == 0);
3562 if ((flags & MALLOCX_TCACHE_MASK) == MALLOCX_TCACHE_NONE) {
3563 tcache = NULL;
3564 } else {
3565 tcache = tcaches_get(tsd, MALLOCX_TCACHE_GET(flags));
3566 }
3567 } else {
3568 if (likely(fast)) {
3569 tcache = tsd_tcachep_get(tsd);
3570 assert(tcache == tcache_get(tsd));
3571 } else {
3572 if (likely(tsd_reentrancy_level_get(tsd) == 0)) {
3573 tcache = tcache_get(tsd);
3574 } else {
3575 tcache = NULL;
3576 }
3577 }
3578 }
3579
3580 UTRACE(ptr, 0, 0);
3581 if (likely(fast)) {
3582 tsd_assert_fast(tsd);
3583 isfree(tsd, ptr, usize, tcache, false);
3584 } else {
3585 uintptr_t args_raw[3] = {(uintptr_t)ptr, size, flags};
3586 hook_invoke_dalloc(hook_dalloc_sdallocx, ptr, args_raw);
3587 isfree(tsd, ptr, usize, tcache, true);
3588 }
3589 check_entry_exit_locking(tsd_tsdn(tsd));
3590
3591}
3592
3593JEMALLOC_EXPORT void JEMALLOC_NOTHROW
3594je_sdallocx(void *ptr, size_t size, int flags) {

Callers 2

je_sdallocxFunction · 0.85
je_sdallocx_noflagsFunction · 0.85

Calls 12

hook_invoke_dallocFunction · 0.85
malloc_initializedFunction · 0.70
inallocxFunction · 0.70
check_entry_exit_lockingFunction · 0.70
isfreeFunction · 0.70
tsd_fetchFunction · 0.50
tsd_fastFunction · 0.50
tsd_tsdnFunction · 0.50
isallocFunction · 0.50
tcaches_getFunction · 0.50
tcache_getFunction · 0.50
tsd_assert_fastFunction · 0.50

Tested by

no test coverage detected