qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for 4.0 1/2] 9p: use g_new(T, n) instead of g_malloc(sizeof(T) * n)
@ 2018-11-29 15:47 Greg Kurz
  2018-11-29 15:47 ` [Qemu-devel] [PATCH for 4.0 2/2] xen/9pfs: " Greg Kurz
  2018-11-29 16:26 ` [Qemu-devel] [PATCH for 4.0 1/2] 9p: " Anthony PERARD
  0 siblings, 2 replies; 5+ messages in thread
From: Greg Kurz @ 2018-11-29 15:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: Greg Kurz, Stefano Stabellini, Anthony Perard

Because it is a recommended coding practice (see HACKING).

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/9pfs/9p.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index bdf7919abfc5..55821343e594 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1331,8 +1331,8 @@ static void coroutine_fn v9fs_walk(void *opaque)
     trace_v9fs_walk(pdu->tag, pdu->id, fid, newfid, nwnames);
 
     if (nwnames && nwnames <= P9_MAXWELEM) {
-        wnames = g_malloc0(sizeof(wnames[0]) * nwnames);
-        qids   = g_malloc0(sizeof(qids[0]) * nwnames);
+        wnames = g_new0(V9fsString, nwnames);
+        qids   = g_new0(V9fsQID, nwnames);
         for (i = 0; i < nwnames; i++) {
             err = pdu_unmarshal(pdu, offset, "s", &wnames[i]);
             if (err < 0) {

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

end of thread, other threads:[~2018-11-29 16:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-29 15:47 [Qemu-devel] [PATCH for 4.0 1/2] 9p: use g_new(T, n) instead of g_malloc(sizeof(T) * n) Greg Kurz
2018-11-29 15:47 ` [Qemu-devel] [PATCH for 4.0 2/2] xen/9pfs: " Greg Kurz
2018-11-29 16:16   ` Anthony PERARD
2018-11-29 16:26 ` [Qemu-devel] [PATCH for 4.0 1/2] 9p: " Anthony PERARD
2018-11-29 16:38   ` Greg Kurz

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).