| 9 | #ifdef BITMAP_USE_TREE |
| 10 | |
| 11 | void |
| 12 | bitmap_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 | |
| 39 | static size_t |
| 40 | bitmap_info_ngroups(const bitmap_info_t *binfo) { |
no outgoing calls