| 230 | } |
| 231 | |
| 232 | static void mi_thread_data_free( mi_thread_data_t* tdfree ) { |
| 233 | // try to add the thread metadata to the cache |
| 234 | for (int i = 0; i < TD_CACHE_SIZE; i++) { |
| 235 | mi_thread_data_t* td = mi_atomic_load_ptr_relaxed(mi_thread_data_t, &td_cache[i]); |
| 236 | if (td == NULL) { |
| 237 | mi_thread_data_t* expected = NULL; |
| 238 | if (mi_atomic_cas_ptr_weak_acq_rel(mi_thread_data_t, &td_cache[i], &expected, tdfree)) { |
| 239 | return; |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | // if that fails, just free it directly |
| 244 | _mi_os_free(tdfree, sizeof(mi_thread_data_t), &_mi_stats_main); |
| 245 | } |
| 246 | |
| 247 | static void mi_thread_data_collect(void) { |
| 248 | // free all thread metadata from the cache |
no test coverage detected