+
+HBitmap *hbitmap_copy(const HBitmap *bitmap)
+{
+ int i;
+ int64_t size;
+ HBitmap *hb = g_memdup(bitmap, sizeof(struct HBitmap));
+
+ size = bitmap->size;
+ for (i = HBITMAP_LEVELS; i-- > 0; ) {
+ size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1);
+ hb->levels[i] = g_memdup(bitmap->levels[i],
+ size * sizeof(unsigned long));
+ }
+
+ return hb;
+}
"(size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL" - will be zero iff size == 0. Is it really possible in qemu? If not, we doesn't need MAX(..., 1).
There is similar construction in older "hbitmap_alloc" function.
--
Best regards,
Vladimir