summaryrefslogtreecommitdiff
path: root/src/lib/bitmap.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-05-24 15:08:33 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-05-24 15:13:04 +0200
commita3ede18c5d3e652e9d0bade4b28193e666198574 (patch)
treee9c464bb98632d9b41f2bc5e7f9c2849e5405f5d /src/lib/bitmap.c
parent3d887b172c37c4418c6173048e6a317eb0c36e57 (diff)
downloadouroboros-a3ede18c5d3e652e9d0bade4b28193e666198574.tar.gz
ouroboros-a3ede18c5d3e652e9d0bade4b28193e666198574.zip
lib: Fix bug in bitmap
Diffstat (limited to 'src/lib/bitmap.c')
-rw-r--r--src/lib/bitmap.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/lib/bitmap.c b/src/lib/bitmap.c
index bf9bb99d..ec663ec7 100644
--- a/src/lib/bitmap.c
+++ b/src/lib/bitmap.c
@@ -50,7 +50,7 @@ static size_t find_next_zero_bit(const size_t * addr,
tmp = ~addr[start];
while (!tmp) {
start++;
- if (start >= (nbits / BITS_PER_LONG))
+ if (start >= DIV_ROUND_UP(nbits, BITS_PER_LONG))
return nbits;
tmp = ~addr[start];
@@ -69,8 +69,7 @@ static size_t find_next_zero_bit(const size_t * addr,
static void bitmap_zero(size_t * dst,
size_t nbits)
{
- size_t len = BITS_TO_LONGS(nbits) * sizeof(size_t);
- memset(dst, 0, len);
+ memset(dst, 0, BITS_TO_LONGS(nbits) * sizeof(size_t));
}
static void bitmap_clear(size_t * map,
@@ -92,8 +91,8 @@ static void bitmap_set(size_t * map,
}
struct bmp {
- ssize_t offset;
- size_t size;
+ ssize_t offset;
+ size_t size;
size_t * bitmap;
};
@@ -116,7 +115,7 @@ struct bmp * bmp_create(size_t bits,
return NULL;
}
- tmp->size = bits;
+ tmp->size = bits;
tmp->offset = offset;
bitmap_zero(tmp->bitmap, bits);