mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
virbitmap: Allow NULL bitmap in functions returning index of a set/clear bit
virBitmapNextSetBit/virBitmapLastSetBit/virBitmapNextClearBit can be used for iteration of a bitmap. Allow NULL bitmap so that iteration of a bitmap can be simplified in certain cases. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d9e4075d4e
commit
72e3100e82
@ -824,6 +824,9 @@ virBitmapNextSetBit(virBitmap *bitmap,
|
||||
size_t nb;
|
||||
unsigned long bits;
|
||||
|
||||
if (!bitmap)
|
||||
return -1;
|
||||
|
||||
if (pos < 0)
|
||||
pos = -1;
|
||||
|
||||
@ -863,6 +866,9 @@ virBitmapLastSetBit(virBitmap *bitmap)
|
||||
ssize_t sz;
|
||||
unsigned long bits;
|
||||
|
||||
if (!bitmap)
|
||||
return -1;
|
||||
|
||||
/* If bitmap is empty then there is no set bit */
|
||||
if (bitmap->map_len == 0)
|
||||
return -1;
|
||||
@ -916,6 +922,9 @@ virBitmapNextClearBit(virBitmap *bitmap,
|
||||
size_t nb;
|
||||
unsigned long bits;
|
||||
|
||||
if (!bitmap)
|
||||
return -1;
|
||||
|
||||
if (pos < 0)
|
||||
pos = -1;
|
||||
|
||||
|
@ -111,14 +111,11 @@ bool virBitmapIsAllSet(virBitmap *bitmap)
|
||||
bool virBitmapIsAllClear(virBitmap *bitmap)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
|
||||
ssize_t virBitmapNextSetBit(virBitmap *bitmap, ssize_t pos)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
ssize_t virBitmapNextSetBit(virBitmap *bitmap, ssize_t pos);
|
||||
|
||||
ssize_t virBitmapLastSetBit(virBitmap *bitmap)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
ssize_t virBitmapLastSetBit(virBitmap *bitmap);
|
||||
|
||||
ssize_t virBitmapNextClearBit(virBitmap *bitmap, ssize_t pos)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
ssize_t virBitmapNextClearBit(virBitmap *bitmap, ssize_t pos);
|
||||
|
||||
size_t virBitmapCountBits(virBitmap *bitmap)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user