The call of virResctrlMonitorGetStats will allocate the memory for holding cache occupancy or memory bandwidth statistics. This patch added an function, virResctrlMonitorFreeStats, as the opposing action of virResctrlMonitorGetStats to free these memory. Signed-off-by: Wang Huaqiang <huaqiang.wang@xxxxxxxxx> --- src/libvirt_private.syms | 1 + src/util/virresctrl.c | 16 ++++++++++++++++ src/util/virresctrl.h | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8889aaa..5018a13 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2692,6 +2692,7 @@ virResctrlInfoNew; virResctrlMonitorAddPID; virResctrlMonitorCreate; virResctrlMonitorDeterminePath; +virResctrlMonitorFreeStats; virResctrlMonitorGetCacheOccupancy; virResctrlMonitorGetID; virResctrlMonitorNew; diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 3268310..6ffd71f 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2747,6 +2747,22 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor, } +void +virResctrlMonitorFreeStats(virResctrlMonitorStatsPtr *stats, + size_t nstats) +{ + size_t i = 0; + + if (!stats) + return; + + for (i = 0; i < nstats; i++) + VIR_FREE(stats[i]); + + VIR_FREE(stats); +} + + /* * virResctrlMonitorGetCacheOccupancy * diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index e2ed4ee..8ea9758 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -231,4 +231,8 @@ int virResctrlMonitorGetCacheOccupancy(virResctrlMonitorPtr monitor, virResctrlMonitorStatsPtr **stats, size_t *nstats); + +void +virResctrlMonitorFreeStats(virResctrlMonitorStatsPtr *stats, + size_t nstats); #endif /* __VIR_RESCTRL_H__ */ -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list