This is called from the `mi_malloc_generic`
| 427 | |
| 428 | // This is called from the `mi_malloc_generic` |
| 429 | void mi_thread_init(void) mi_attr_noexcept |
| 430 | { |
| 431 | // ensure our process has started already |
| 432 | mi_process_init(); |
| 433 | |
| 434 | // initialize the thread local default heap |
| 435 | // (this will call `_mi_heap_set_default_direct` and thus set the |
| 436 | // fiber/pthread key to a non-zero value, ensuring `_mi_thread_done` is called) |
| 437 | if (_mi_heap_init()) return; // returns true if already initialized |
| 438 | |
| 439 | _mi_stat_increase(&_mi_stats_main.threads, 1); |
| 440 | mi_atomic_increment_relaxed(&thread_count); |
| 441 | //_mi_verbose_message("thread init: 0x%zx\n", _mi_thread_id()); |
| 442 | } |
| 443 | |
| 444 | void mi_thread_done(void) mi_attr_noexcept { |
| 445 | _mi_thread_done(mi_get_default_heap()); |
no test coverage detected