initialize a bitmap to all unset; avoid a mem_zero if `already_zero` is true returns the size of the bitmap
| 1032 | // initialize a bitmap to all unset; avoid a mem_zero if `already_zero` is true |
| 1033 | // returns the size of the bitmap |
| 1034 | size_t mi_bitmap_init(mi_bitmap_t* bitmap, size_t bit_count, bool already_zero) { |
| 1035 | size_t chunk_count; |
| 1036 | const size_t size = mi_bitmap_size(bit_count, &chunk_count); |
| 1037 | if (!already_zero) { |
| 1038 | _mi_memzero_aligned(bitmap, size); |
| 1039 | } |
| 1040 | mi_atomic_store_release(&bitmap->chunk_count, chunk_count); |
| 1041 | mi_assert_internal(mi_atomic_load_relaxed(&bitmap->chunk_count) <= MI_BITMAP_MAX_CHUNK_COUNT); |
| 1042 | return size; |
| 1043 | } |
| 1044 | |
| 1045 | |
| 1046 | // Set a sequence of `n` bits in the bitmap (and can cross chunks). Not atomic so only use if local to a thread. |
no test coverage detected