1 Star 0 Fork 126

wanglmb/qemu

forked from src-openEuler/qemu 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
migration-dirtyrate-Replace-malloc-with-g_new.patch 1.61 KB
Copy Edit Raw Blame History
yezengruan authored 2022-11-03 19:44 . Qemu update to version 6.2.0-55
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wanglmb/qemu.git
git@gitee.com:wanglmb/qemu.git
wanglmb
qemu
qemu
master

Search