]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
5ffa42cb TG |
2 | #pragma once |
3 | ||
11c3a366 TA |
4 | #include <stdbool.h> |
5 | ||
cb57dd41 | 6 | #include "hashmap.h" |
71d35b6b | 7 | #include "macro.h" |
5ffa42cb TG |
8 | |
9 | typedef struct Bitmap Bitmap; | |
10 | ||
11 | Bitmap *bitmap_new(void); | |
17c8de63 | 12 | Bitmap *bitmap_copy(Bitmap *b); |
5ffa42cb | 13 | int bitmap_ensure_allocated(Bitmap **b); |
17c8de63 | 14 | void bitmap_free(Bitmap *b); |
5ffa42cb TG |
15 | |
16 | int bitmap_set(Bitmap *b, unsigned n); | |
17 | void bitmap_unset(Bitmap *b, unsigned n); | |
18 | bool bitmap_isset(Bitmap *b, unsigned n); | |
19 | bool bitmap_isclear(Bitmap *b); | |
20 | void bitmap_clear(Bitmap *b); | |
21 | ||
cb57dd41 | 22 | bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n); |
5ffa42cb TG |
23 | |
24 | bool bitmap_equal(Bitmap *a, Bitmap *b); | |
25 | ||
cb57dd41 TG |
26 | #define BITMAP_FOREACH(n, b, i) \ |
27 | for ((i).idx = 0; bitmap_iterate((b), &(i), (unsigned*)&(n)); ) | |
5ffa42cb TG |
28 | |
29 | DEFINE_TRIVIAL_CLEANUP_FUNC(Bitmap*, bitmap_free); | |
30 | ||
31 | #define _cleanup_bitmap_free_ _cleanup_(bitmap_freep) |