| 818 | } |
| 819 | |
| 820 | static prof_gctx_t * |
| 821 | prof_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 | |
| 846 | static void |
| 847 | prof_gctx_try_destroy(tsd_t *tsd, prof_tdata_t *tdata_self, prof_gctx_t *gctx, |
no test coverage detected