*
* Allocate an empty bitmap. It can be used with self-expanding APIs.
*
- * Returns a pointer to the allocated bitmap or NULL if memory cannot be
- * allocated. Reports libvirt errors.
+ * Returns a pointer to the allocated bitmap.
*/
virBitmapPtr
virBitmapNewEmpty(void)
{
- virBitmapPtr ret;
-
- ignore_value(VIR_ALLOC(ret));
-
- return ret;
+ return g_new0(virBitmap, 1);
}
virBitmapPtr
virBitmapParseUnlimited(const char *str)
{
- virBitmapPtr bitmap;
+ virBitmapPtr bitmap = virBitmapNewEmpty();
bool neg = false;
const char *cur = str;
char *tmp;
size_t i;
int start, last;
- if (!(bitmap = virBitmapNewEmpty()))
- return NULL;
-
if (!str)
goto error;
goto cleanup;
/* enumerate sockets in the node */
- if (!(sockets_map = virBitmapNewEmpty()))
- goto cleanup;
+ sockets_map = virBitmapNewEmpty();
while ((direrr = virDirRead(cpudir, &cpudirent, node)) > 0) {
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
goto cleanup;
for (i = 0; i < sock_max; i++)
- if (!(cores_maps[i] = virBitmapNewEmpty()))
- goto cleanup;
+ cores_maps[i] = virBitmapNewEmpty();
/* Iterate over all CPUs in the node, in ascending order */
for (cpu = 0; cpu < npresent_cpus; cpu++) {
if (virCommandRun(cmd, &exitstatus) < 0)
return NULL;
- if (!(bitmap = virBitmapNewEmpty()))
- return NULL;
+ bitmap = virBitmapNewEmpty();
/* older version does not support --print-capabilties -- that's fine */
if (exitstatus != 0) {
/* 0. empty set */
- if (!(bitmap = virBitmapNewEmpty()))
- goto error;
+ bitmap = virBitmapNewEmpty();
if (virBitmapNextSetBit(bitmap, -1) != -1)
goto error;
static int
test12(const void *opaque G_GNUC_UNUSED)
{
- virBitmapPtr map = NULL;
+ virBitmapPtr map = virBitmapNewEmpty();
int ret = -1;
- if (!(map = virBitmapNewEmpty()))
- return -1;
-
TEST_MAP(0, "");
if (virBitmapSetBitExpand(map, 128) < 0)