virnumamock: Use automatic memory freeing for virBitmap

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-12-06 14:10:40 +01:00
parent 33eb88cdc9
commit f89c929b1e

View File

@ -63,29 +63,23 @@ virNumaIsAvailable(void)
int int
virNumaGetMaxNode(void) virNumaGetMaxNode(void)
{ {
int ret = -1; g_autoptr(virBitmap) map = NULL;
virBitmap *map = NULL;
if (virFileReadValueBitmap(&map, "%s/node/online", SYSFS_SYSTEM_PATH) < 0) if (virFileReadValueBitmap(&map, "%s/node/online", SYSFS_SYSTEM_PATH) < 0)
return -1; return -1;
ret = virBitmapLastSetBit(map); return virBitmapLastSetBit(map);
virBitmapFree(map);
return ret;
} }
bool bool
virNumaNodeIsAvailable(int node) virNumaNodeIsAvailable(int node)
{ {
bool ret = false; g_autoptr(virBitmap) map = NULL;
virBitmap *map = NULL;
if (virFileReadValueBitmap(&map, "%s/node/online", SYSFS_SYSTEM_PATH) < 0) if (virFileReadValueBitmap(&map, "%s/node/online", SYSFS_SYSTEM_PATH) < 0)
return false; return false;
ret = virBitmapIsBitSet(map, node); return virBitmapIsBitSet(map, node);
virBitmapFree(map);
return ret;
} }
int int