@@ -622,7 +622,7 @@ arenas_i2a(size_t i) {
622622}
623623
624624static ctl_arena_t *
625- arenas_i_impl (tsdn_t * tsdn , size_t i , bool compat , bool init ) {
625+ arenas_i_impl (tsd_t * tsd , size_t i , bool compat , bool init ) {
626626 ctl_arena_t * ret ;
627627
628628 assert (!compat || !init );
@@ -635,15 +635,15 @@ arenas_i_impl(tsdn_t *tsdn, size_t i, bool compat, bool init) {
635635 ctl_arena_stats_t astats ;
636636 };
637637 struct container_s * cont =
638- (struct container_s * )base_alloc (tsdn , b0get ( ),
639- sizeof (struct container_s ), QUANTUM );
638+ (struct container_s * )base_alloc (tsd_tsdn ( tsd ),
639+ b0get (), sizeof (struct container_s ), QUANTUM );
640640 if (cont == NULL ) {
641641 return NULL ;
642642 }
643643 ret = & cont -> ctl_arena ;
644644 ret -> astats = & cont -> astats ;
645645 } else {
646- ret = (ctl_arena_t * )base_alloc (tsdn , b0get (),
646+ ret = (ctl_arena_t * )base_alloc (tsd_tsdn ( tsd ) , b0get (),
647647 sizeof (ctl_arena_t ), QUANTUM );
648648 if (ret == NULL ) {
649649 return NULL ;
@@ -659,7 +659,7 @@ arenas_i_impl(tsdn_t *tsdn, size_t i, bool compat, bool init) {
659659
660660static ctl_arena_t *
661661arenas_i (size_t i ) {
662- ctl_arena_t * ret = arenas_i_impl (TSDN_NULL , i , true, false);
662+ ctl_arena_t * ret = arenas_i_impl (tsd_fetch () , i , true, false);
663663 assert (ret != NULL );
664664 return ret ;
665665}
@@ -863,7 +863,7 @@ ctl_arena_refresh(tsdn_t *tsdn, arena_t *arena, ctl_arena_t *ctl_sdarena,
863863}
864864
865865static unsigned
866- ctl_arena_init (tsdn_t * tsdn , extent_hooks_t * extent_hooks ) {
866+ ctl_arena_init (tsd_t * tsd , extent_hooks_t * extent_hooks ) {
867867 unsigned arena_ind ;
868868 ctl_arena_t * ctl_arena ;
869869
@@ -876,12 +876,12 @@ ctl_arena_init(tsdn_t *tsdn, extent_hooks_t *extent_hooks) {
876876 }
877877
878878 /* Trigger stats allocation. */
879- if (arenas_i_impl (tsdn , arena_ind , false, true) == NULL ) {
879+ if (arenas_i_impl (tsd , arena_ind , false, true) == NULL ) {
880880 return UINT_MAX ;
881881 }
882882
883883 /* Initialize new arena. */
884- if (arena_init (tsdn , arena_ind , extent_hooks ) == NULL ) {
884+ if (arena_init (tsd_tsdn ( tsd ) , arena_ind , extent_hooks ) == NULL ) {
885885 return UINT_MAX ;
886886 }
887887
@@ -975,8 +975,9 @@ ctl_refresh(tsdn_t *tsdn) {
975975}
976976
977977static bool
978- ctl_init (tsdn_t * tsdn ) {
978+ ctl_init (tsd_t * tsd ) {
979979 bool ret ;
980+ tsdn_t * tsdn = tsd_tsdn (tsd );
980981
981982 malloc_mutex_lock (tsdn , & ctl_mtx );
982983 if (!ctl_initialized ) {
@@ -1010,14 +1011,14 @@ ctl_init(tsdn_t *tsdn) {
10101011 * here rather than doing it lazily elsewhere, in order
10111012 * to limit when OOM-caused errors can occur.
10121013 */
1013- if ((ctl_sarena = arenas_i_impl (tsdn , MALLCTL_ARENAS_ALL , false,
1014+ if ((ctl_sarena = arenas_i_impl (tsd , MALLCTL_ARENAS_ALL , false,
10141015 true)) == NULL ) {
10151016 ret = true;
10161017 goto label_return ;
10171018 }
10181019 ctl_sarena -> initialized = true;
10191020
1020- if ((ctl_darena = arenas_i_impl (tsdn , MALLCTL_ARENAS_DESTROYED ,
1021+ if ((ctl_darena = arenas_i_impl (tsd , MALLCTL_ARENAS_DESTROYED ,
10211022 false, true)) == NULL ) {
10221023 ret = true;
10231024 goto label_return ;
@@ -1031,7 +1032,7 @@ ctl_init(tsdn_t *tsdn) {
10311032
10321033 ctl_arenas -> narenas = narenas_total_get ();
10331034 for (i = 0 ; i < ctl_arenas -> narenas ; i ++ ) {
1034- if (arenas_i_impl (tsdn , i , false, true) == NULL ) {
1035+ if (arenas_i_impl (tsd , i , false, true) == NULL ) {
10351036 ret = true;
10361037 goto label_return ;
10371038 }
@@ -1156,7 +1157,7 @@ ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
11561157 size_t mib [CTL_MAX_DEPTH ];
11571158 const ctl_named_node_t * node ;
11581159
1159- if (!ctl_initialized && ctl_init (tsd_tsdn ( tsd ) )) {
1160+ if (!ctl_initialized && ctl_init (tsd )) {
11601161 ret = EAGAIN ;
11611162 goto label_return ;
11621163 }
@@ -1180,15 +1181,15 @@ ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
11801181}
11811182
11821183int
1183- ctl_nametomib (tsdn_t * tsdn , const char * name , size_t * mibp , size_t * miblenp ) {
1184+ ctl_nametomib (tsd_t * tsd , const char * name , size_t * mibp , size_t * miblenp ) {
11841185 int ret ;
11851186
1186- if (!ctl_initialized && ctl_init (tsdn )) {
1187+ if (!ctl_initialized && ctl_init (tsd )) {
11871188 ret = EAGAIN ;
11881189 goto label_return ;
11891190 }
11901191
1191- ret = ctl_lookup (tsdn , name , NULL , mibp , miblenp );
1192+ ret = ctl_lookup (tsd_tsdn ( tsd ) , name , NULL , mibp , miblenp );
11921193label_return :
11931194 return (ret );
11941195}
@@ -1200,7 +1201,7 @@ ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
12001201 const ctl_named_node_t * node ;
12011202 size_t i ;
12021203
1203- if (!ctl_initialized && ctl_init (tsd_tsdn ( tsd ) )) {
1204+ if (!ctl_initialized && ctl_init (tsd )) {
12041205 ret = EAGAIN ;
12051206 goto label_return ;
12061207 }
@@ -2312,8 +2313,7 @@ arenas_create_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
23122313
23132314 extent_hooks = (extent_hooks_t * )& extent_hooks_default ;
23142315 WRITE (extent_hooks , extent_hooks_t * );
2315- if ((arena_ind = ctl_arena_init (tsd_tsdn (tsd ), extent_hooks )) ==
2316- UINT_MAX ) {
2316+ if ((arena_ind = ctl_arena_init (tsd , extent_hooks )) == UINT_MAX ) {
23172317 ret = EAGAIN ;
23182318 goto label_return ;
23192319 }
0 commit comments