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

Function prof_gctx_create

deps/jemalloc/src/prof.c:820–844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

818}
819
820static prof_gctx_t *
821prof_gctx_create(tsdn_t *tsdn, prof_bt_t *bt) {
822 /*
823 * Create a single allocation that has space for vec of length bt->len.
824 */
825 size_t size = offsetof(prof_gctx_t, vec) + (bt->len * sizeof(void *));
826 prof_gctx_t *gctx = (prof_gctx_t *)iallocztm(tsdn, size,
827 sz_size2index(size), false, NULL, true, arena_get(TSDN_NULL, 0, true),
828 true);
829 if (gctx == NULL) {
830 return NULL;
831 }
832 gctx->lock = prof_gctx_mutex_choose();
833 /*
834 * Set nlimbo to 1, in order to avoid a race condition with
835 * prof_tctx_destroy()/prof_gctx_try_destroy().
836 */
837 gctx->nlimbo = 1;
838 tctx_tree_new(&gctx->tctxs);
839 /* Duplicate bt. */
840 memcpy(gctx->vec, bt->vec, bt->len * sizeof(void *));
841 gctx->bt.vec = gctx->vec;
842 gctx->bt.len = bt->len;
843 return gctx;
844}
845
846static void
847prof_gctx_try_destroy(tsd_t *tsd, prof_tdata_t *tdata_self, prof_gctx_t *gctx,

Callers 1

prof_lookup_globalFunction · 0.70

Calls 4

prof_gctx_mutex_chooseFunction · 0.70
iallocztmFunction · 0.50
sz_size2indexFunction · 0.50
arena_getFunction · 0.50

Tested by

no test coverage detected