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

Function isfree

deps/jemalloc/src/jemalloc.c:2594–2648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2592}
2593
2594JEMALLOC_ALWAYS_INLINE void
2595isfree(tsd_t *tsd, void *ptr, size_t usize, tcache_t *tcache, bool slow_path) {
2596 if (!slow_path) {
2597 tsd_assert_fast(tsd);
2598 }
2599 check_entry_exit_locking(tsd_tsdn(tsd));
2600 if (tsd_reentrancy_level_get(tsd) != 0) {
2601 assert(slow_path);
2602 }
2603
2604 assert(ptr != NULL);
2605 assert(malloc_initialized() || IS_INITIALIZER);
2606
2607 alloc_ctx_t alloc_ctx, *ctx;
2608 if (!config_cache_oblivious && ((uintptr_t)ptr & PAGE_MASK) != 0) {
2609 /*
2610 * When cache_oblivious is disabled and ptr is not page aligned,
2611 * the allocation was not sampled -- usize can be used to
2612 * determine szind directly.
2613 */
2614 alloc_ctx.szind = sz_size2index(usize);
2615 alloc_ctx.slab = true;
2616 ctx = &alloc_ctx;
2617 if (config_debug) {
2618 alloc_ctx_t dbg_ctx;
2619 rtree_ctx_t *rtree_ctx = tsd_rtree_ctx(tsd);
2620 rtree_szind_slab_read(tsd_tsdn(tsd), &extents_rtree,
2621 rtree_ctx, (uintptr_t)ptr, true, &dbg_ctx.szind,
2622 &dbg_ctx.slab);
2623 assert(dbg_ctx.szind == alloc_ctx.szind);
2624 assert(dbg_ctx.slab == alloc_ctx.slab);
2625 }
2626 } else if (config_prof && opt_prof) {
2627 rtree_ctx_t *rtree_ctx = tsd_rtree_ctx(tsd);
2628 rtree_szind_slab_read(tsd_tsdn(tsd), &extents_rtree, rtree_ctx,
2629 (uintptr_t)ptr, true, &alloc_ctx.szind, &alloc_ctx.slab);
2630 assert(alloc_ctx.szind == sz_size2index(usize));
2631 ctx = &alloc_ctx;
2632 } else {
2633 ctx = NULL;
2634 }
2635
2636 if (config_prof && opt_prof) {
2637 prof_free(tsd, ptr, usize, ctx);
2638 }
2639 if (config_stats) {
2640 *tsd_thread_deallocatedp_get(tsd) += usize;
2641 }
2642
2643 if (likely(!slow_path)) {
2644 isdalloct(tsd_tsdn(tsd), ptr, usize, tcache, ctx, false);
2645 } else {
2646 isdalloct(tsd_tsdn(tsd), ptr, usize, tcache, ctx, true);
2647 }
2648}
2649
2650JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
2651void JEMALLOC_NOTHROW *

Callers 1

sdallocx_defaultFunction · 0.70

Calls 8

check_entry_exit_lockingFunction · 0.70
malloc_initializedFunction · 0.70
tsd_assert_fastFunction · 0.50
tsd_tsdnFunction · 0.50
sz_size2indexFunction · 0.50
rtree_szind_slab_readFunction · 0.50
prof_freeFunction · 0.50
isdalloctFunction · 0.50

Tested by

no test coverage detected