qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] migration/dirtyrate: Replace malloc with g_new
@ 2022-04-11  9:47 jianchunfu
  2022-04-11 11:30 ` Dr. David Alan Gilbert
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jianchunfu @ 2022-04-11  9:47 UTC (permalink / raw)
  To: richard.henderson; +Cc: qemu-devel, jianchunfu, dgilbert, quintela

Using macro g_new() to handling potential memory allocation failures
in dirtyrate.

Signed-off-by: jianchunfu <jianchunfu@cmss.chinamobile.com>
---
 migration/dirtyrate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index aace12a787..0e59aacbb0 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -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();
 
-- 
2.18.4





^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-11 21:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-11  9:47 [PATCH] migration/dirtyrate: Replace malloc with g_new jianchunfu
2022-04-11 11:30 ` Dr. David Alan Gilbert
2022-04-11 18:08 ` Richard Henderson
2022-04-11 21:44 ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).