MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / mi_bbitmap_try_clearNC

Function mi_bbitmap_try_clearNC

system/lib/mimalloc/src/bitmap.c:1702–1717  ·  view source on GitHub ↗

Try to clear `n` bits at `idx` where `n <= MI_BCHUNK_BITS`.

Source from the content-addressed store, hash-verified

1700
1701// Try to clear `n` bits at `idx` where `n <= MI_BCHUNK_BITS`.
1702bool mi_bbitmap_try_clearNC(mi_bbitmap_t* bbitmap, size_t idx, size_t n) {
1703 mi_assert_internal(n>0);
1704 mi_assert_internal(n<=MI_BCHUNK_BITS);
1705 mi_assert_internal(idx + n <= mi_bbitmap_max_bits(bbitmap));
1706
1707 const size_t chunk_idx = idx / MI_BCHUNK_BITS;
1708 const size_t cidx = idx % MI_BCHUNK_BITS;
1709 mi_assert_internal(cidx + n <= MI_BCHUNK_BITS); // don't cross chunks (for now)
1710 mi_assert_internal(chunk_idx < mi_bbitmap_chunk_count(bbitmap));
1711 if (cidx + n > MI_BCHUNK_BITS) return false;
1712 bool maybe_all_clear = false;
1713 const bool cleared = mi_bchunk_try_clearN(&bbitmap->chunks[chunk_idx], cidx, n, &maybe_all_clear);
1714 if (cleared && maybe_all_clear) { mi_bbitmap_chunkmap_try_clear(bbitmap, chunk_idx); }
1715 // note: we don't set the size class for an explicit try_clearN (only used by purging)
1716 return cleared;
1717}
1718
1719
1720

Callers 2

bitmap.hFile · 0.85
mi_arena_try_purge_rangeFunction · 0.85

Calls 2

mi_bchunk_try_clearNFunction · 0.85

Tested by

no test coverage detected