summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/basic/bitmap.c3
-rw-r--r--src/test/test-bitmap.c8
2 files changed, 11 insertions, 0 deletions
diff --git a/src/basic/bitmap.c b/src/basic/bitmap.c
index e7e19b3b66..7ea3357031 100644
--- a/src/basic/bitmap.c
+++ b/src/basic/bitmap.c
@@ -145,7 +145,10 @@ bool bitmap_isclear(Bitmap *b) {
void bitmap_clear(Bitmap *b) {
assert(b);
+ free(b->bitmaps);
+ b->bitmaps = NULL;
b->n_bitmaps = 0;
+ b->bitmaps_allocated = 0;
}
bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n) {
diff --git a/src/test/test-bitmap.c b/src/test/test-bitmap.c
index cb9e4a41f6..ff22117745 100644
--- a/src/test/test-bitmap.c
+++ b/src/test/test-bitmap.c
@@ -111,5 +111,13 @@ int main(int argc, const char *argv[]) {
bitmap_unset(b, 0);
assert_se(bitmap_equal(b, b2));
+ assert_se(bitmap_set(b, 1) == 0);
+ bitmap_clear(b);
+ assert_se(bitmap_equal(b, b2));
+
+ assert_se(bitmap_set(b, 0) == 0);
+ assert_se(bitmap_set(b2, 0) == 0);
+ assert_se(bitmap_equal(b, b2));
+
return 0;
}