Add an API allowing flags from one virBitmapPtr to be copied
into another instance.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
# bitmap.h
virBitmapAlloc;
virBitmapClearBit;
+virBitmapCopy;
virBitmapFree;
virBitmapGetBit;
virBitmapSetBit;
}
}
+
+int virBitmapCopy(virBitmapPtr dst, virBitmapPtr src)
+{
+ size_t sz;
+
+ if (dst->size != src->size) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ sz = (src->size + VIR_BITMAP_BITS_PER_UNIT - 1) /
+ VIR_BITMAP_BITS_PER_UNIT;
+
+ memcpy(dst->map, src->map, sz * sizeof(src->map[0]));
+
+ return 0;
+}
+
+
/**
* virBitmapSetBit:
* @bitmap: Pointer to bitmap
*/
void virBitmapFree(virBitmapPtr bitmap);
+/*
+ * Copy all bits from @src to @dst. The bitmap sizes
+ * must be the same
+ */
+int virBitmapCopy(virBitmapPtr dst, virBitmapPtr src);
+
/*
* Set bit position @b in @bitmap
*/