mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 20:45:18 +00:00
virHostCPUParseNode: 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:
parent
20ddaa9797
commit
8366175482
@ -300,10 +300,10 @@ virHostCPUParseNode(const char *node,
|
|||||||
int processors = 0;
|
int processors = 0;
|
||||||
g_autoptr(DIR) cpudir = NULL;
|
g_autoptr(DIR) cpudir = NULL;
|
||||||
struct dirent *cpudirent = NULL;
|
struct dirent *cpudirent = NULL;
|
||||||
virBitmap *node_cpus_map = NULL;
|
g_autoptr(virBitmap) sockets_map = virBitmapNew(0);
|
||||||
virBitmap *sockets_map = NULL;
|
|
||||||
virBitmap **cores_maps = NULL;
|
virBitmap **cores_maps = NULL;
|
||||||
int npresent_cpus = virBitmapSize(present_cpus_map);
|
int npresent_cpus = virBitmapSize(present_cpus_map);
|
||||||
|
g_autoptr(virBitmap) node_cpus_map = virBitmapNew(npresent_cpus);
|
||||||
unsigned int sock_max = 0;
|
unsigned int sock_max = 0;
|
||||||
unsigned int sock;
|
unsigned int sock;
|
||||||
unsigned int core;
|
unsigned int core;
|
||||||
@ -319,12 +319,6 @@ virHostCPUParseNode(const char *node,
|
|||||||
if (virDirOpen(&cpudir, node) < 0)
|
if (virDirOpen(&cpudir, node) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* Keep track of the CPUs that belong to the current node */
|
|
||||||
node_cpus_map = virBitmapNew(npresent_cpus);
|
|
||||||
|
|
||||||
/* enumerate sockets in the node */
|
|
||||||
sockets_map = virBitmapNew(0);
|
|
||||||
|
|
||||||
while ((direrr = virDirRead(cpudir, &cpudirent, node)) > 0) {
|
while ((direrr = virDirRead(cpudir, &cpudirent, node)) > 0) {
|
||||||
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
|
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
|
||||||
continue;
|
continue;
|
||||||
@ -437,8 +431,6 @@ virHostCPUParseNode(const char *node,
|
|||||||
for (i = 0; i < sock_max; i++)
|
for (i = 0; i < sock_max; i++)
|
||||||
virBitmapFree(cores_maps[i]);
|
virBitmapFree(cores_maps[i]);
|
||||||
VIR_FREE(cores_maps);
|
VIR_FREE(cores_maps);
|
||||||
virBitmapFree(sockets_map);
|
|
||||||
virBitmapFree(node_cpus_map);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user