From: Matt Coleman Date: Thu, 21 Jan 2021 18:51:27 +0000 (-0500) Subject: hyperv: use g_autoptr for Win32_OperatingSystem in hypervNodeGetFreeMemory X-Git-Tag: v7.1.0-rc1~454 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59daea438e37b1358d42a0c762c43b6ac12fa528;p=thirdparty%2Flibvirt.git hyperv: use g_autoptr for Win32_OperatingSystem in hypervNodeGetFreeMemory Signed-off-by: Matt Coleman Reviewed-by: Laine Stump --- 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; }