return true;
}
+/**
+ * virBitmapIsAllClear:
+ * @bitmap: the bitmap to check
+ *
+ * check if all bits in @bitmap are clear
+ */
+bool virBitmapIsAllClear(virBitmapPtr bitmap)
+{
+ int i;
+
+ for (i = 0; i < bitmap->map_len; i++)
+ if (bitmap->map[i] != 0)
+ return false;
+
+ return true;
+}
+
/**
* virBitmapNextSetBit:
* @bitmap: the bitmap
goto error;
virBitmapClearAll(bitmap);
+ if (!virBitmapIsAllClear(bitmap))
+ goto error;
if (testBit(bitmap, 0, size - 1, false) < 0)
goto error;
if (virBitmapCountBits(bitmap) != 0)
if (!virBitmapIsAllSet(bitmap))
goto error;
+ virBitmapClearAll(bitmap);
+ if (!virBitmapIsAllClear(bitmap))
+ goto error;
ret = 0;
error:
if (virBitmapNextClearBit(bitmap, i) != -1)
goto error;
+ if (!virBitmapIsAllClear(bitmap))
+ goto error;
+
virBitmapFree(bitmap);
bitmap = NULL;
if (!virBitmapIsAllSet(bitmap))
goto error;
+ virBitmapClearAll(bitmap);
+ if (!virBitmapIsAllClear(bitmap))
+ goto error;
+
virBitmapFree(bitmap);
}
return -1;
}
+static int test8(const void *v ATTRIBUTE_UNUSED)
+{
+ virBitmapPtr bitmap = NULL;
+ char data[108] = {0x00,};
+
+ bitmap = virBitmapNewData(data, sizeof(data));
+ if (!bitmap)
+ goto error;
+
+ if (!virBitmapIsAllClear(bitmap))
+ goto error;
+
+ if (virBitmapSetBit(bitmap, 11) < 0)
+ goto error;
+
+ if (virBitmapIsAllClear(bitmap))
+ goto error;
+
+ return 0;
+error:
+ virBitmapFree(bitmap);
+ return -1;
+}
+
static int
mymain(void)
{
ret = -1;
if (virtTestRun("test7", 1, test7, NULL) < 0)
ret = -1;
-
+ if (virtTestRun("test8", 1, test8, NULL) < 0)
+ ret = -1;
return ret;
}