Lines Matching refs:b

31 Bitmap* bitmap_copy(Bitmap *b) {  in bitmap_copy()  argument
38 ret->bitmaps = newdup(uint64_t, b->bitmaps, b->n_bitmaps); in bitmap_copy()
42 ret->n_bitmaps = b->n_bitmaps; in bitmap_copy()
46 Bitmap* bitmap_free(Bitmap *b) { in bitmap_free() argument
47 if (!b) in bitmap_free()
50 free(b->bitmaps); in bitmap_free()
51 return mfree(b); in bitmap_free()
54 int bitmap_ensure_allocated(Bitmap **b) { in bitmap_ensure_allocated() argument
57 assert(b); in bitmap_ensure_allocated()
59 if (*b) in bitmap_ensure_allocated()
66 *b = a; in bitmap_ensure_allocated()
71 int bitmap_set(Bitmap *b, unsigned n) { in bitmap_set() argument
75 assert(b); in bitmap_set()
83 if (offset >= b->n_bitmaps) { in bitmap_set()
84 if (!GREEDY_REALLOC0(b->bitmaps, offset + 1)) in bitmap_set()
87 b->n_bitmaps = offset + 1; in bitmap_set()
92 b->bitmaps[offset] |= bitmask; in bitmap_set()
97 void bitmap_unset(Bitmap *b, unsigned n) { in bitmap_unset() argument
101 if (!b) in bitmap_unset()
106 if (offset >= b->n_bitmaps) in bitmap_unset()
111 b->bitmaps[offset] &= ~bitmask; in bitmap_unset()
114 bool bitmap_isset(const Bitmap *b, unsigned n) { in bitmap_isset() argument
118 if (!b) in bitmap_isset()
123 if (offset >= b->n_bitmaps) in bitmap_isset()
128 return !!(b->bitmaps[offset] & bitmask); in bitmap_isset()
131 bool bitmap_isclear(const Bitmap *b) { in bitmap_isclear() argument
134 if (!b) in bitmap_isclear()
137 for (i = 0; i < b->n_bitmaps; i++) in bitmap_isclear()
138 if (b->bitmaps[i] != 0) in bitmap_isclear()
144 void bitmap_clear(Bitmap *b) { in bitmap_clear() argument
145 if (!b) in bitmap_clear()
148 b->bitmaps = mfree(b->bitmaps); in bitmap_clear()
149 b->n_bitmaps = 0; in bitmap_clear()
152 bool bitmap_iterate(const Bitmap *b, Iterator *i, unsigned *n) { in bitmap_iterate() argument
159 if (!b || i->idx == BITMAP_END) in bitmap_iterate()
166 for (; offset < b->n_bitmaps; offset ++) { in bitmap_iterate()
167 if (b->bitmaps[offset]) { in bitmap_iterate()
169 if (b->bitmaps[offset] & bitmask) { in bitmap_iterate()
187 bool bitmap_equal(const Bitmap *a, const Bitmap *b) { in bitmap_equal() argument
192 if (a == b) in bitmap_equal()
195 if (!a != !b) in bitmap_equal()
201 common_n_bitmaps = MIN(a->n_bitmaps, b->n_bitmaps); in bitmap_equal()
202 if (memcmp_safe(a->bitmaps, b->bitmaps, sizeof(uint64_t) * common_n_bitmaps) != 0) in bitmap_equal()
205 c = a->n_bitmaps > b->n_bitmaps ? a : b; in bitmap_equal()