[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 2/3] xen/9pfs: use g_new(T, n) instead of g_malloc(si
From: |
Greg Kurz |
Subject: |
[Qemu-devel] [PULL 2/3] xen/9pfs: use g_new(T, n) instead of g_malloc(sizeof(T) * n) |
Date: |
Thu, 13 Dec 2018 10:03:42 +0100 |
Because it is a recommended coding practice (see HACKING).
Signed-off-by: Greg Kurz <address@hidden>
Acked-by: Anthony PERARD <address@hidden>
---
hw/9pfs/xen-9p-backend.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
index 3f54a21c7623..9015fe7773d0 100644
--- a/hw/9pfs/xen-9p-backend.c
+++ b/hw/9pfs/xen-9p-backend.c
@@ -178,7 +178,7 @@ static void xen_9pfs_init_out_iov_from_pdu(V9fsPDU *pdu,
g_free(ring->sg);
- ring->sg = g_malloc0(sizeof(*ring->sg) * 2);
+ ring->sg = g_new0(struct iovec, 2);
xen_9pfs_out_sg(ring, ring->sg, &num, pdu->idx);
*piov = ring->sg;
*pniov = num;
@@ -196,7 +196,7 @@ static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
g_free(ring->sg);
- ring->sg = g_malloc0(sizeof(*ring->sg) * 2);
+ ring->sg = g_new0(struct iovec, 2);
xen_9pfs_in_sg(ring, ring->sg, &num, pdu->idx, size);
buf_size = iov_size(ring->sg, num);
@@ -368,7 +368,7 @@ static int xen_9pfs_connect(struct XenDevice *xendev)
return -1;
}
- xen_9pdev->rings = g_malloc0(xen_9pdev->num_rings * sizeof(Xen9pfsRing));
+ xen_9pdev->rings = g_new0(Xen9pfsRing, xen_9pdev->num_rings);
for (i = 0; i < xen_9pdev->num_rings; i++) {
char *str;
int ring_order;
--
2.17.2
- [Qemu-devel] [PULL 0/3] 9p patches 2018-12-13, Greg Kurz, 2018/12/13
- [Qemu-devel] [PULL 2/3] xen/9pfs: use g_new(T, n) instead of g_malloc(sizeof(T) * n),
Greg Kurz <=
- [Qemu-devel] [PULL 1/3] 9p: use g_new(T, n) instead of g_malloc(sizeof(T) * n), Greg Kurz, 2018/12/13
- [Qemu-devel] [PULL 3/3] 9p: remove support for the "handle" backend, Greg Kurz, 2018/12/13
- Re: [Qemu-devel] [PULL 0/3] 9p patches 2018-12-13, no-reply, 2018/12/13
- Re: [Qemu-devel] [PULL 0/3] 9p patches 2018-12-13, Peter Maydell, 2018/12/14