提交 d2fdeb3b 编写于 作者: D Daniel P. Berrange

Add a virBitmapCopy API

Add an API allowing flags from one virBitmapPtr to be copied
into another instance.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 203ab129
......@@ -8,6 +8,7 @@
# bitmap.h
virBitmapAlloc;
virBitmapClearBit;
virBitmapCopy;
virBitmapFree;
virBitmapGetBit;
virBitmapSetBit;
......
......@@ -93,6 +93,25 @@ void virBitmapFree(virBitmapPtr bitmap)
}
}
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
......
......@@ -41,6 +41,12 @@ virBitmapPtr virBitmapAlloc(size_t size) ATTRIBUTE_RETURN_CHECK;
*/
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
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册