79c4324644
Change-Id: I2d302dda68298877c65c99147f5bf22186a59aac
49 lines
1.6 KiB
Diff
49 lines
1.6 KiB
Diff
From 7cb2d342b9073ec9548202df6e1fb25fa4997d71 Mon Sep 17 00:00:00 2001
|
|
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
|
|
Date: Thu, 30 Jun 2022 11:34:50 +0000
|
|
Subject: [PATCH] migration/dirtyrate: Replace malloc with g_new Using macro
|
|
g_new() to handling potential memory allocation failures in dirtyrate.
|
|
|
|
---
|
|
migration/dirtyrate.c | 8 ++++----
|
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
|
|
index d65e744af9..8043bc7946 100644
|
|
--- a/migration/dirtyrate.c
|
|
+++ b/migration/dirtyrate.c
|
|
@@ -157,7 +157,7 @@ static void cleanup_dirtyrate_stat(struct DirtyRateConfig config)
|
|
{
|
|
/* last calc-dirty-rate qmp use dirty ring mode */
|
|
if (dirtyrate_mode == DIRTY_RATE_MEASURE_MODE_DIRTY_RING) {
|
|
- free(DirtyStat.dirty_ring.rates);
|
|
+ g_free(DirtyStat.dirty_ring.rates);
|
|
DirtyStat.dirty_ring.rates = NULL;
|
|
}
|
|
}
|
|
@@ -522,10 +522,10 @@ static void calculate_dirtyrate_dirty_ring(struct DirtyRateConfig config)
|
|
nvcpu++;
|
|
}
|
|
|
|
- dirty_pages = malloc(sizeof(*dirty_pages) * nvcpu);
|
|
+ dirty_pages = g_new(DirtyPageRecord, nvcpu);
|
|
|
|
DirtyStat.dirty_ring.nvcpu = nvcpu;
|
|
- DirtyStat.dirty_ring.rates = malloc(sizeof(DirtyRateVcpu) * nvcpu);
|
|
+ DirtyStat.dirty_ring.rates = g_new(DirtyRateVcpu, nvcpu);
|
|
|
|
dirtyrate_global_dirty_log_start();
|
|
|
|
@@ -556,7 +556,7 @@ static void calculate_dirtyrate_dirty_ring(struct DirtyRateConfig config)
|
|
}
|
|
|
|
DirtyStat.dirty_rate = dirtyrate_sum;
|
|
- free(dirty_pages);
|
|
+ g_free(dirty_pages);
|
|
}
|
|
|
|
static void calculate_dirtyrate_sample_vm(struct DirtyRateConfig config)
|
|
--
|
|
2.27.0
|
|
|