MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / mi_thread_data_free

Function mi_thread_data_free

3rd/mimalloc-2.0.9/src/init.c:232–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232static 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
247static void mi_thread_data_collect(void) {
248 // free all thread metadata from the cache

Callers 1

_mi_heap_doneFunction · 0.85

Calls 1

_mi_os_freeFunction · 0.85

Tested by

no test coverage detected