summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-07-28 11:04:12 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-07-29 15:54:53 +0200
commit8594c8a552c02fb6fa2bf569e68aa73b739e8da6 (patch)
tree3766764bacaa82d374dbd73dc5d8cc9799d76f16
parentf0d67dcddd4bcbe0a221a4ff4248114e5cf57dd8 (diff)
downloadsystemd-8594c8a552c02fb6fa2bf569e68aa73b739e8da6.tar.gz
shared/bitmap: constify various operators which don't modify bitmap
-rw-r--r--src/shared/bitmap.c11
-rw-r--r--src/shared/bitmap.h8
2 files changed, 9 insertions, 10 deletions
diff --git a/src/shared/bitmap.c b/src/shared/bitmap.c
index a956a42cab..de28b1055a 100644
--- a/src/shared/bitmap.c
+++ b/src/shared/bitmap.c
@@ -117,7 +117,7 @@ void bitmap_unset(Bitmap *b, unsigned n) {
b->bitmaps[offset] &= ~bitmask;
}
-bool bitmap_isset(Bitmap *b, unsigned n) {
+bool bitmap_isset(const Bitmap *b, unsigned n) {
uint64_t bitmask;
unsigned offset;
@@ -134,7 +134,7 @@ bool bitmap_isset(Bitmap *b, unsigned n) {
return !!(b->bitmaps[offset] & bitmask);
}
-bool bitmap_isclear(Bitmap *b) {
+bool bitmap_isclear(const Bitmap *b) {
unsigned i;
if (!b)
@@ -148,7 +148,6 @@ bool bitmap_isclear(Bitmap *b) {
}
void bitmap_clear(Bitmap *b) {
-
if (!b)
return;
@@ -157,7 +156,7 @@ void bitmap_clear(Bitmap *b) {
b->bitmaps_allocated = 0;
}
-bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n) {
+bool bitmap_iterate(const Bitmap *b, Iterator *i, unsigned *n) {
uint64_t bitmask;
unsigned offset, rem;
@@ -192,9 +191,9 @@ bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n) {
return false;
}
-bool bitmap_equal(Bitmap *a, Bitmap *b) {
+bool bitmap_equal(const Bitmap *a, const Bitmap *b) {
size_t common_n_bitmaps;
- Bitmap *c;
+ const Bitmap *c;
unsigned i;
if (a == b)
diff --git a/src/shared/bitmap.h b/src/shared/bitmap.h
index 843d27d24d..611a3e0e9d 100644
--- a/src/shared/bitmap.h
+++ b/src/shared/bitmap.h
@@ -15,13 +15,13 @@ void bitmap_free(Bitmap *b);
int bitmap_set(Bitmap *b, unsigned n);
void bitmap_unset(Bitmap *b, unsigned n);
-bool bitmap_isset(Bitmap *b, unsigned n);
-bool bitmap_isclear(Bitmap *b);
+bool bitmap_isset(const Bitmap *b, unsigned n);
+bool bitmap_isclear(const Bitmap *b);
void bitmap_clear(Bitmap *b);
-bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n);
+bool bitmap_iterate(const Bitmap *b, Iterator *i, unsigned *n);
-bool bitmap_equal(Bitmap *a, Bitmap *b);
+bool bitmap_equal(const Bitmap *a, const Bitmap *b);
#define BITMAP_FOREACH(n, b, i) \
for ((i).idx = 0; bitmap_iterate((b), &(i), (unsigned*)&(n)); )