+ hex_dump (0, b->bits, byte_cnt (b->bit_cnt), false);
+}
+
+/* Returns the number of bytes required to accomodate a bitmap
+ with BIT_CNT bits. */
+size_t
+bitmap_needed_bytes (size_t bit_cnt)
+{
+ return sizeof (struct bitmap) + byte_cnt (bit_cnt);
+}
+
+/* Creates and returns a bitmap with BIT_CNT bits in the
+ BLOCK_SIZE bytes of storage preallocated at BLOCK.
+ BLOCK_SIZE must be at least bitmap_needed_bytes(BIT_CNT). */
+struct bitmap *
+bitmap_create_preallocated (size_t bit_cnt, void *block, size_t block_size)
+{
+ struct bitmap *b = block;
+
+ ASSERT (block_size >= bitmap_needed_bytes (bit_cnt));
+
+ b->bit_cnt = bit_cnt;
+ b->bits = (elem_type *) (b + 1);
+ bitmap_set_all (b, false);
+ return b;