[PATCH 06/10] resctrl: Add virResctrlInfoPerTypeFree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It will be easier to add more dynamic data later on.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/util/virresctrl.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index daa344ec989b..30695092a168 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -197,6 +197,17 @@ virResctrlInfoMemBWFree(virResctrlInfoMemBW *ptr)
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virResctrlInfoMemBW, virResctrlInfoMemBWFree);
 
+static void
+virResctrlInfoPerTypeFree(virResctrlInfoPerType *ptr)
+{
+    if (!ptr)
+        return;
+
+    g_free(ptr);
+}
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virResctrlInfoPerType, virResctrlInfoPerTypeFree);
+
 
 static void
 virResctrlInfoDispose(void *obj)
@@ -214,7 +225,7 @@ virResctrlInfoDispose(void *obj)
 
         if (level->types) {
             for (j = 0; j < VIR_CACHE_TYPE_LAST; j++)
-                g_free(level->types[j]);
+                virResctrlInfoPerTypeFree(level->types[j]);
         }
         g_free(level->types);
         g_free(level);
@@ -539,7 +550,7 @@ virResctrlGetCacheInfo(virResctrlInfo *resctrl,
         int type = 0;
         unsigned int level = 0;
         virResctrlInfoPerLevel *i_level = NULL;
-        g_autofree virResctrlInfoPerType *i_type = NULL;
+        g_autoptr(virResctrlInfoPerType) i_type = NULL;
 
         VIR_DEBUG("Parsing info type '%s'", ent->d_name);
         if (ent->d_name[0] != 'L')
-- 
2.46.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux