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

Function mi_arena_alloc

3rd/mimalloc-2.0.9/src/arena.c:140–148  ·  view source on GitHub ↗

----------------------------------------------------------- Thread safe allocation in an arena ----------------------------------------------------------- */

Source from the content-addressed store, hash-verified

138 Thread safe allocation in an arena
139----------------------------------------------------------- */
140static bool mi_arena_alloc(mi_arena_t* arena, size_t blocks, mi_bitmap_index_t* bitmap_idx)
141{
142 size_t idx = 0; // mi_atomic_load_relaxed(&arena->search_idx); // start from last search; ok to be relaxed as the exact start does not matter
143 if (_mi_bitmap_try_find_from_claim_across(arena->blocks_inuse, arena->field_count, idx, blocks, bitmap_idx)) {
144 mi_atomic_store_relaxed(&arena->search_idx, mi_bitmap_index_field(*bitmap_idx)); // start search from found location next time around
145 return true;
146 };
147 return false;
148}
149
150
151/* -----------------------------------------------------------

Callers 1

mi_arena_alloc_fromFunction · 0.85

Calls 2

mi_bitmap_index_fieldFunction · 0.85

Tested by

no test coverage detected