From 7c40f1ead9142265e4853b7ced3fc068f12eadd2 Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Thu, 12 Sep 2024 13:14:02 +0200 Subject: [PATCH] resctrl: Add virResctrlInfoMemBWFree It will be easier to add more dynamic data later on Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- src/util/virresctrl.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 000191c5d4..daa344ec98 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -186,6 +186,17 @@ struct _virResctrlInfo { virResctrlInfoMongrp *monitor_info; }; +static void +virResctrlInfoMemBWFree(virResctrlInfoMemBW *ptr) +{ + if (!ptr) + return; + + g_free(ptr); +} + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virResctrlInfoMemBW, virResctrlInfoMemBWFree); + static void virResctrlInfoDispose(void *obj) @@ -212,7 +223,8 @@ virResctrlInfoDispose(void *obj) if (resctrl->monitor_info) g_strfreev(resctrl->monitor_info->features); - g_free(resctrl->membw_info); + virResctrlInfoMemBWFree(resctrl->membw_info); + g_free(resctrl->levels); g_free(resctrl->monitor_info); } @@ -628,7 +640,7 @@ static int virResctrlGetMemoryBandwidthInfo(virResctrlInfo *resctrl) { int rv = -1; - g_autofree virResctrlInfoMemBW *i_membw = NULL; + g_autoptr(virResctrlInfoMemBW) i_membw = NULL; /* query memory bandwidth allocation info */ i_membw = g_new0(virResctrlInfoMemBW, 1);