Initialize the allocation/free handler pointers. Caller is responsible for ensuring this routine is called exactly once. The routine attempts to dynamically link with the TBB memory allocator. If that allocator is not found, it links to malloc and free. */
| 132 | The routine attempts to dynamically link with the TBB memory allocator. |
| 133 | If that allocator is not found, it links to malloc and free. */ |
| 134 | void initialize_handler_pointers() { |
| 135 | __TBB_ASSERT(allocate_handler == &initialize_allocate_handler, nullptr); |
| 136 | bool success = dynamic_link(MALLOCLIB_NAME, MallocLinkTable, 4); |
| 137 | if(!success) { |
| 138 | // If unsuccessful, set the handlers to the default routines. |
| 139 | // This must be done now, and not before FillDynamicLinks runs, because if other |
| 140 | // threads call the handlers, we want them to go through the DoOneTimeInitializations logic, |
| 141 | // which forces them to wait. |
| 142 | allocate_handler_unsafe = &std::malloc; |
| 143 | deallocate_handler = &std::free; |
| 144 | cache_aligned_allocate_handler_unsafe = &std_cache_aligned_allocate; |
| 145 | cache_aligned_deallocate_handler = &std_cache_aligned_deallocate; |
| 146 | } |
| 147 | |
| 148 | allocate_handler.store(allocate_handler_unsafe, std::memory_order_release); |
| 149 | cache_aligned_allocate_handler.store(cache_aligned_allocate_handler_unsafe, std::memory_order_release); |
| 150 | |
| 151 | PrintExtraVersionInfo( "ALLOCATOR", success?"scalable_malloc":"malloc" ); |
| 152 | } |
| 153 | |
| 154 | static std::once_flag initialization_state; |
| 155 | void initialize_cache_aligned_allocator() { |
nothing calls this directly
no test coverage detected