mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 13:05:27 +00:00
Add a virBitmapCopy API
Add an API allowing flags from one virBitmapPtr to be copied into another instance. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
203ab129af
commit
d2fdeb3b1e
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user