MCPcopy Create free account
hub / github.com/ElementsProject/lightning / bitmap_fill_range

Function bitmap_fill_range

ccan/ccan/bitmap/bitmap.c:37–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37void bitmap_fill_range(bitmap *b, unsigned long n, unsigned long m)
38{
39 unsigned long an = BIT_ALIGN_UP(n);
40 unsigned long am = BIT_ALIGN_DOWN(m);
41 bitmap_word headmask = BITMAP_WORD_1 >> (n % BITMAP_WORD_BITS);
42 bitmap_word tailmask = ~(BITMAP_WORD_1 >> (m % BITMAP_WORD_BITS));
43
44 assert(m >= n);
45
46 if (am < an) {
47 BITMAP_WORD(b, n) |= bitmap_bswap(headmask & tailmask);
48 return;
49 }
50
51 if (an > n)
52 BITMAP_WORD(b, n) |= bitmap_bswap(headmask);
53
54 if (am > an)
55 memset(&BITMAP_WORD(b, an), 0xff,
56 (am - an) / BITMAP_WORD_BITS * sizeof(bitmap_word));
57
58 if (m > am)
59 BITMAP_WORD(b, m) |= bitmap_bswap(tailmask);
60}
61
62static int bitmap_clz(bitmap_word w)
63{

Callers 5

bitmap_realloc1Function · 0.85
test_sizeFunction · 0.85
test_sizeFunction · 0.85
blacklist_to_bitmapFunction · 0.85
json_blacklistruneFunction · 0.85

Calls 1

bitmap_bswapFunction · 0.85

Tested by 2

test_sizeFunction · 0.68
test_sizeFunction · 0.68