From: Marc-André Lureau <marcandre.lur...@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> [PMD: added hw/dma/etraxfs_dma.c] --- dma-helpers.c | 4 ++-- hw/dma/etraxfs_dma.c | 2 +- hw/dma/rc4030.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dma-helpers.c b/dma-helpers.c index 2d7e02d35e..e327fc21c4 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -40,7 +40,7 @@ int dma_memory_set(AddressSpace *as, dma_addr_t addr, uint8_t c, dma_addr_t len) void qemu_sglist_init(QEMUSGList *qsg, DeviceState *dev, int alloc_hint, AddressSpace *as) { - qsg->sg = g_malloc(alloc_hint * sizeof(ScatterGatherEntry)); + qsg->sg = g_new(ScatterGatherEntry, alloc_hint); qsg->nsg = 0; qsg->nalloc = alloc_hint; qsg->size = 0; @@ -53,7 +53,7 @@ void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len) { if (qsg->nsg == qsg->nalloc) { qsg->nalloc = 2 * qsg->nalloc + 1; - qsg->sg = g_realloc(qsg->sg, qsg->nalloc * sizeof(ScatterGatherEntry)); + qsg->sg = g_renew(ScatterGatherEntry, qsg->sg, qsg->nalloc); } qsg->sg[qsg->nsg].base = base; qsg->sg[qsg->nsg].len = len; diff --git a/hw/dma/etraxfs_dma.c b/hw/dma/etraxfs_dma.c index d5650eb885..97951a2abe 100644 --- a/hw/dma/etraxfs_dma.c +++ b/hw/dma/etraxfs_dma.c @@ -768,7 +768,7 @@ void *etraxfs_dmac_init(hwaddr base, int nr_channels) { struct fs_dma_ctrl *ctrl = NULL; - ctrl = g_malloc0(sizeof *ctrl); + ctrl = g_new0(struct fs_dma_ctrl, 1); ctrl->bh = qemu_bh_new(DMA_run, ctrl); diff --git a/hw/dma/rc4030.c b/hw/dma/rc4030.c index 5d4833eeca..14bcab9fb3 100644 --- a/hw/dma/rc4030.c +++ b/hw/dma/rc4030.c @@ -636,8 +636,8 @@ static rc4030_dma *rc4030_allocate_dmas(void *opaque, int n) struct rc4030DMAState *p; int i; - s = (rc4030_dma *)g_malloc0(sizeof(rc4030_dma) * n); - p = (struct rc4030DMAState *)g_malloc0(sizeof(struct rc4030DMAState) * n); + s = g_new0(rc4030_dma, n); + p = g_new0(struct rc4030DMAState, n); for (i = 0; i < n; i++) { p->opaque = opaque; p->n = i; -- 2.14.2