From 59daea438e37b1358d42a0c762c43b6ac12fa528 Mon Sep 17 00:00:00 2001 From: Matt Coleman Date: Thu, 21 Jan 2021 13:51:27 -0500 Subject: [PATCH] hyperv: use g_autoptr for Win32_OperatingSystem in hypervNodeGetFreeMemory Signed-off-by: Matt Coleman Reviewed-by: Laine Stump --- src/hyperv/hyperv_driver.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 84ffb24f1a..bd3c5a7c34 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -2701,9 +2701,8 @@ hypervDomainGetSchedulerParameters(virDomainPtr domain, static unsigned long long hypervNodeGetFreeMemory(virConnectPtr conn) { - unsigned long long freeMemoryBytes = 0; hypervPrivate *priv = conn->privateData; - Win32_OperatingSystem *operatingSystem = NULL; + g_autoptr(Win32_OperatingSystem) operatingSystem = NULL; if (hypervGetOperatingSystem(priv, &operatingSystem) < 0) return 0; @@ -2715,11 +2714,7 @@ hypervNodeGetFreeMemory(virConnectPtr conn) return 0; } - freeMemoryBytes = operatingSystem->data->FreePhysicalMemory * 1024; - - hypervFreeObject((hypervObject *)operatingSystem); - - return freeMemoryBytes; + return operatingSystem->data->FreePhysicalMemory * 1024; }