MCPcopy Create free account
hub / github.com/beefytech/Beef / free_default

Function free_default

BeefRT/JEMalloc/src/jemalloc.c:2994–3026  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2992}
2993
2994JEMALLOC_NOINLINE
2995void
2996free_default(void *ptr) {
2997 UTRACE(ptr, 0, 0);
2998 if (likely(ptr != NULL)) {
2999 /*
3000 * We avoid setting up tsd fully (e.g. tcache, arena binding)
3001 * based on only free() calls -- other activities trigger the
3002 * minimal to full transition. This is because free() may
3003 * happen during thread shutdown after tls deallocation: if a
3004 * thread never had any malloc activities until then, a
3005 * fully-setup tsd won't be destructed properly.
3006 */
3007 tsd_t *tsd = tsd_fetch_min();
3008 check_entry_exit_locking(tsd_tsdn(tsd));
3009
3010 if (likely(tsd_fast(tsd))) {
3011 tcache_t *tcache = tcache_get_from_ind(tsd,
3012 TCACHE_IND_AUTOMATIC, /* slow */ false,
3013 /* is_alloc */ false);
3014 ifree(tsd, ptr, tcache, /* slow */ false);
3015 } else {
3016 tcache_t *tcache = tcache_get_from_ind(tsd,
3017 TCACHE_IND_AUTOMATIC, /* slow */ true,
3018 /* is_alloc */ false);
3019 uintptr_t args_raw[3] = {(uintptr_t)ptr};
3020 hook_invoke_dalloc(hook_dalloc_free, ptr, args_raw);
3021 ifree(tsd, ptr, tcache, /* slow */ true);
3022 }
3023
3024 check_entry_exit_locking(tsd_tsdn(tsd));
3025 }
3026}
3027
3028JEMALLOC_ALWAYS_INLINE bool
3029free_fastpath_nonfast_aligned(void *ptr, bool check_prof) {

Callers 1

je_freeFunction · 0.85

Calls 7

tsd_fetch_minFunction · 0.85
check_entry_exit_lockingFunction · 0.85
tsd_tsdnFunction · 0.85
tsd_fastFunction · 0.85
tcache_get_from_indFunction · 0.85
ifreeFunction · 0.85
hook_invoke_dallocFunction · 0.85

Tested by

no test coverage detected