| 1001 | } |
| 1002 | |
| 1003 | static unsigned |
| 1004 | ctl_arena_init(tsd_t *tsd, extent_hooks_t *extent_hooks) { |
| 1005 | unsigned arena_ind; |
| 1006 | ctl_arena_t *ctl_arena; |
| 1007 | |
| 1008 | if ((ctl_arena = ql_last(&ctl_arenas->destroyed, destroyed_link)) != |
| 1009 | NULL) { |
| 1010 | ql_remove(&ctl_arenas->destroyed, ctl_arena, destroyed_link); |
| 1011 | arena_ind = ctl_arena->arena_ind; |
| 1012 | } else { |
| 1013 | arena_ind = ctl_arenas->narenas; |
| 1014 | } |
| 1015 | |
| 1016 | /* Trigger stats allocation. */ |
| 1017 | if (arenas_i_impl(tsd, arena_ind, false, true) == NULL) { |
| 1018 | return UINT_MAX; |
| 1019 | } |
| 1020 | |
| 1021 | /* Initialize new arena. */ |
| 1022 | if (arena_init(tsd_tsdn(tsd), arena_ind, extent_hooks) == NULL) { |
| 1023 | return UINT_MAX; |
| 1024 | } |
| 1025 | |
| 1026 | if (arena_ind == ctl_arenas->narenas) { |
| 1027 | ctl_arenas->narenas++; |
| 1028 | } |
| 1029 | |
| 1030 | return arena_ind; |
| 1031 | } |
| 1032 | |
| 1033 | static void |
| 1034 | ctl_background_thread_stats_read(tsdn_t *tsdn) { |
no test coverage detected