MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / bitmap_info_init

Function bitmap_info_init

deps/jemalloc/src/bitmap.c:11–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#ifdef BITMAP_USE_TREE
10
11void
12bitmap_info_init(bitmap_info_t *binfo, size_t nbits) {
13 unsigned i;
14 size_t group_count;
15
16 assert(nbits > 0);
17 assert(nbits <= (ZU(1) << LG_BITMAP_MAXBITS));
18
19 /*
20 * Compute the number of groups necessary to store nbits bits, and
21 * progressively work upward through the levels until reaching a level
22 * that requires only one group.
23 */
24 binfo->levels[0].group_offset = 0;
25 group_count = BITMAP_BITS2GROUPS(nbits);
26 for (i = 1; group_count > 1; i++) {
27 assert(i < BITMAP_MAX_LEVELS);
28 binfo->levels[i].group_offset = binfo->levels[i-1].group_offset
29 + group_count;
30 group_count = BITMAP_BITS2GROUPS(group_count);
31 }
32 binfo->levels[i].group_offset = binfo->levels[i-1].group_offset
33 + group_count;
34 assert(binfo->levels[i].group_offset <= BITMAP_GROUPS_MAX);
35 binfo->nlevels = i;
36 binfo->nbits = nbits;
37}
38
39static size_t
40bitmap_info_ngroups(const bitmap_info_t *binfo) {

Callers 2

bitmap.cFile · 0.50

Calls

no outgoing calls

Tested by 1