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

Function free_default

deps/jemalloc/src/jemalloc.c:2769–2803  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2767}
2768
2769JEMALLOC_NOINLINE
2770void
2771free_default(void *ptr) {
2772 UTRACE(ptr, 0, 0);
2773 if (likely(ptr != NULL)) {
2774 /*
2775 * We avoid setting up tsd fully (e.g. tcache, arena binding)
2776 * based on only free() calls -- other activities trigger the
2777 * minimal to full transition. This is because free() may
2778 * happen during thread shutdown after tls deallocation: if a
2779 * thread never had any malloc activities until then, a
2780 * fully-setup tsd won't be destructed properly.
2781 */
2782 tsd_t *tsd = tsd_fetch_min();
2783 check_entry_exit_locking(tsd_tsdn(tsd));
2784
2785 tcache_t *tcache;
2786 if (likely(tsd_fast(tsd))) {
2787 tsd_assert_fast(tsd);
2788 /* Unconditionally get tcache ptr on fast path. */
2789 tcache = tsd_tcachep_get(tsd);
2790 ifree(tsd, ptr, tcache, false);
2791 } else {
2792 if (likely(tsd_reentrancy_level_get(tsd) == 0)) {
2793 tcache = tcache_get(tsd);
2794 } else {
2795 tcache = NULL;
2796 }
2797 uintptr_t args_raw[3] = {(uintptr_t)ptr};
2798 hook_invoke_dalloc(hook_dalloc_free, ptr, args_raw);
2799 ifree(tsd, ptr, tcache, true);
2800 }
2801 check_entry_exit_locking(tsd_tsdn(tsd));
2802 }
2803}
2804
2805JEMALLOC_ALWAYS_INLINE
2806bool free_fastpath(void *ptr, size_t size, bool size_hint) {

Callers 1

je_freeFunction · 0.85

Calls 8

hook_invoke_dallocFunction · 0.85
check_entry_exit_lockingFunction · 0.70
ifreeFunction · 0.70
tsd_fetch_minFunction · 0.50
tsd_tsdnFunction · 0.50
tsd_fastFunction · 0.50
tsd_assert_fastFunction · 0.50
tcache_getFunction · 0.50

Tested by

no test coverage detected