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

Function tcaches_create

deps/jemalloc/src/tcache.c:650–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

648}
649
650bool
651tcaches_create(tsd_t *tsd, unsigned *r_ind) {
652 witness_assert_depth(tsdn_witness_tsdp_get(tsd_tsdn(tsd)), 0);
653
654 bool err;
655
656 if (tcaches_create_prep(tsd)) {
657 err = true;
658 goto label_return;
659 }
660
661 tcache_t *tcache = tcache_create_explicit(tsd);
662 if (tcache == NULL) {
663 err = true;
664 goto label_return;
665 }
666
667 tcaches_t *elm;
668 malloc_mutex_lock(tsd_tsdn(tsd), &tcaches_mtx);
669 if (tcaches_avail != NULL) {
670 elm = tcaches_avail;
671 tcaches_avail = tcaches_avail->next;
672 elm->tcache = tcache;
673 *r_ind = (unsigned)(elm - tcaches);
674 } else {
675 elm = &tcaches[tcaches_past];
676 elm->tcache = tcache;
677 *r_ind = tcaches_past;
678 tcaches_past++;
679 }
680 malloc_mutex_unlock(tsd_tsdn(tsd), &tcaches_mtx);
681
682 err = false;
683label_return:
684 witness_assert_depth(tsdn_witness_tsdp_get(tsd_tsdn(tsd)), 0);
685 return err;
686}
687
688static tcache_t *
689tcaches_elm_remove(tsd_t *tsd, tcaches_t *elm, bool allow_reinit) {

Callers 1

tcache_create_ctlFunction · 0.70

Calls 6

tcaches_create_prepFunction · 0.70
tcache_create_explicitFunction · 0.70
witness_assert_depthFunction · 0.50
tsd_tsdnFunction · 0.50
malloc_mutex_lockFunction · 0.50
malloc_mutex_unlockFunction · 0.50

Tested by

no test coverage detected