aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--acl.c14
-rw-r--r--aio.c6
-rw-r--r--arch_init.c4
-rw-r--r--async.c4
-rw-r--r--audio/alsaaudio.c10
-rw-r--r--audio/audio.c30
-rw-r--r--audio/audio_template.h20
-rw-r--r--audio/esdaudio.c8
-rw-r--r--audio/mixeng.c2
-rw-r--r--audio/ossaudio.c4
-rw-r--r--audio/paaudio.c8
-rw-r--r--audio/wavaudio.c4
-rw-r--r--audio/wavcapture.c12
-rw-r--r--audio/winwaveaudio.c16
-rw-r--r--bitmap.h2
-rw-r--r--block-migration.c40
-rw-r--r--block.c34
-rw-r--r--block/blkdebug.c4
-rw-r--r--block/bochs.c4
-rw-r--r--block/cloop.c6
-rw-r--r--block/curl.c10
-rw-r--r--block/dmg.c14
-rw-r--r--block/nbd.c18
-rw-r--r--block/parallels.c6
-rw-r--r--block/qcow.c36
-rw-r--r--block/qcow2-cache.c8
-rw-r--r--block/qcow2-cluster.c12
-rw-r--r--block/qcow2-refcount.c34
-rw-r--r--block/qcow2-snapshot.c38
-rw-r--r--block/qcow2.c36
-rw-r--r--block/qed-check.c4
-rw-r--r--block/qed-cluster.c4
-rw-r--r--block/qed-gencb.c4
-rw-r--r--block/qed-l2-cache.c6
-rw-r--r--block/qed.c8
-rw-r--r--block/raw.c2
-rw-r--r--block/rbd.c26
-rw-r--r--block/sheepdog.c52
-rw-r--r--block/vdi.c16
-rw-r--r--block/vmdk.c22
-rw-r--r--block/vpc.c8
-rw-r--r--block/vvfat.c32
-rw-r--r--blockdev.c14
-rw-r--r--bsd-user/mmap.c16
-rw-r--r--bsd-user/syscall.c4
-rw-r--r--bt-host.c2
-rw-r--r--bt-vhci.c2
-rw-r--r--buffered_file.c8
-rw-r--r--check-qdict.c6
-rw-r--r--check-qfloat.c2
-rw-r--r--check-qint.c2
-rw-r--r--check-qlist.c8
-rw-r--r--check-qstring.c4
-rw-r--r--console.c26
-rw-r--r--coroutine-gthread.c8
-rw-r--r--coroutine-ucontext.c16
-rw-r--r--coroutine-win32.c4
-rw-r--r--cpus.c8
-rw-r--r--cris-dis.c12
-rw-r--r--cursor.c4
-rw-r--r--cutils.c6
-rw-r--r--device_tree.c4
-rw-r--r--dma-helpers.c6
-rw-r--r--error.c10
-rw-r--r--exec.c48
-rw-r--r--fsdev/qemu-fsdev.c8
-rw-r--r--gdbstub.c8
-rw-r--r--hw/9pfs/cofs.c4
-rw-r--r--hw/9pfs/virtio-9p-device.c8
-rw-r--r--hw/9pfs/virtio-9p-xattr.c4
-rw-r--r--hw/9pfs/virtio-9p.c124
-rw-r--r--hw/acpi.c10
-rw-r--r--hw/adb.c4
-rw-r--r--hw/adlib.c4
-rw-r--r--hw/applesmc.c2
-rw-r--r--hw/arm_timer.c2
-rw-r--r--hw/axis_dev88.c2
-rw-r--r--hw/baum.c18
-rw-r--r--hw/bitbang_i2c.c2
-rw-r--r--hw/blizzard.c8
-rw-r--r--hw/bt-hci-csr.c2
-rw-r--r--hw/bt-hci.c20
-rw-r--r--hw/bt-hid.c4
-rw-r--r--hw/bt-l2cap.c18
-rw-r--r--hw/bt-sdp.c20
-rw-r--r--hw/bt.c6
-rw-r--r--hw/cbus.c6
-rw-r--r--hw/ccid-card-emulated.c16
-rw-r--r--hw/cirrus_vga.c8
-rw-r--r--hw/dp8393x.c4
-rw-r--r--hw/ds1225y.c2
-rw-r--r--hw/eepro100.c2
-rw-r--r--hw/eeprom93xx.c4
-rw-r--r--hw/elf_ops.h26
-rw-r--r--hw/etraxfs_dma.c4
-rw-r--r--hw/etraxfs_eth.c2
-rw-r--r--hw/fw_cfg.c16
-rw-r--r--hw/g364fb.c2
-rw-r--r--hw/grlib_gptimer.c2
-rw-r--r--hw/grlib_irqmp.c2
-rw-r--r--hw/gus.c2
-rw-r--r--hw/heathrow_pic.c2
-rw-r--r--hw/i8259.c2
-rw-r--r--hw/ide/ahci.c4
-rw-r--r--hw/ide/macio.c2
-rw-r--r--hw/ide/microdrive.c4
-rw-r--r--hw/ide/mmio.c2
-rw-r--r--hw/ide/qdev.c4
-rw-r--r--hw/intel-hda.c4
-rw-r--r--hw/irq.c10
-rw-r--r--hw/isa_mmio.c2
-rw-r--r--hw/ivshmem.c12
-rw-r--r--hw/jazz_led.c2
-rw-r--r--hw/leon3.c2
-rw-r--r--hw/lm32_boards.c4
-rw-r--r--hw/lm32_hwsetup.h8
-rw-r--r--hw/loader.c48
-rw-r--r--hw/lsi53c895a.c12
-rw-r--r--hw/m48t59.c2
-rw-r--r--hw/mac_dbdma.c2
-rw-r--r--hw/mac_nvram.c4
-rw-r--r--hw/mcf5206.c4
-rw-r--r--hw/mcf5208.c2
-rw-r--r--hw/mcf_fec.c4
-rw-r--r--hw/mcf_intc.c2
-rw-r--r--hw/mcf_uart.c2
-rw-r--r--hw/milkymist.c2
-rw-r--r--hw/mips_fulong2e.c4
-rw-r--r--hw/mips_jazz.c4
-rw-r--r--hw/mips_malta.c6
-rw-r--r--hw/mips_mipssim.c4
-rw-r--r--hw/mips_r4k.c6
-rw-r--r--hw/mipsnet.c4
-rw-r--r--hw/msix.c12
-rw-r--r--hw/msmouse.c4
-rw-r--r--hw/multiboot.c10
-rw-r--r--hw/nand.c2
-rw-r--r--hw/nseries.c8
-rw-r--r--hw/omap.h2
-rw-r--r--hw/omap1.c20
-rw-r--r--hw/omap2.c10
-rw-r--r--hw/omap_clk.c2
-rw-r--r--hw/omap_dma.c4
-rw-r--r--hw/omap_dss.c4
-rw-r--r--hw/omap_gpio.c4
-rw-r--r--hw/omap_gpmc.c2
-rw-r--r--hw/omap_gptimer.c2
-rw-r--r--hw/omap_i2c.c4
-rw-r--r--hw/omap_intc.c4
-rw-r--r--hw/omap_l4.c18
-rw-r--r--hw/omap_lcdc.c2
-rw-r--r--hw/omap_mmc.c4
-rw-r--r--hw/omap_sdrc.c2
-rw-r--r--hw/omap_spi.c2
-rw-r--r--hw/omap_synctimer.c2
-rw-r--r--hw/omap_uart.c2
-rw-r--r--hw/onenand.c30
-rw-r--r--hw/openpic.c6
-rw-r--r--hw/parallel.c2
-rw-r--r--hw/pc.c22
-rw-r--r--hw/pc_piix.c2
-rw-r--r--hw/pci.c46
-rw-r--r--hw/pcie_aer.c4
-rw-r--r--hw/pcie_port.c2
-rw-r--r--hw/pckbd.c2
-rw-r--r--hw/petalogix_ml605_mmu.c4
-rw-r--r--hw/petalogix_s3adsp1800_mmu.c4
-rw-r--r--hw/pflash_cfi01.c4
-rw-r--r--hw/pflash_cfi02.c4
-rw-r--r--hw/ppc.c8
-rw-r--r--hw/ppc405_boards.c8
-rw-r--r--hw/ppc405_uc.c28
-rw-r--r--hw/ppc440.c4
-rw-r--r--hw/ppc440_bamboo.c4
-rw-r--r--hw/ppc4xx_devs.c4
-rw-r--r--hw/ppc4xx_pci.c4
-rw-r--r--hw/ppc_newworld.c8
-rw-r--r--hw/ppc_oldworld.c8
-rw-r--r--hw/ppc_prep.c6
-rw-r--r--hw/ppce500_mpc8544ds.c8
-rw-r--r--hw/prep_pci.c2
-rw-r--r--hw/ps2.c4
-rw-r--r--hw/ptimer.c2
-rw-r--r--hw/pxa2xx.c12
-rw-r--r--hw/pxa2xx_dma.c2
-rw-r--r--hw/pxa2xx_keypad.c2
-rw-r--r--hw/pxa2xx_lcd.c2
-rw-r--r--hw/pxa2xx_mmci.c2
-rw-r--r--hw/pxa2xx_pcmcia.c2
-rw-r--r--hw/qdev-properties.c8
-rw-r--r--hw/qdev.c20
-rw-r--r--hw/qxl-render.c4
-rw-r--r--hw/qxl.c4
-rw-r--r--hw/r2d.c4
-rw-r--r--hw/rc4030.c6
-rw-r--r--hw/rtl8139.c12
-rw-r--r--hw/s390-virtio.c8
-rw-r--r--hw/scsi-bus.c4
-rw-r--r--hw/scsi-disk.c4
-rw-r--r--hw/scsi-generic.c8
-rw-r--r--hw/sd.c6
-rw-r--r--hw/serial.c4
-rw-r--r--hw/sh7750.c2
-rw-r--r--hw/sh_intc.c2
-rw-r--r--hw/sh_serial.c2
-rw-r--r--hw/sh_timer.c4
-rw-r--r--hw/slavio_timer.c2
-rw-r--r--hw/sm501.c2
-rw-r--r--hw/smbios.c8
-rw-r--r--hw/smbus_eeprom.c2
-rw-r--r--hw/soc_dma.c8
-rw-r--r--hw/spapr.c20
-rw-r--r--hw/spapr_vio.c2
-rw-r--r--hw/spapr_vscsi.c2
-rw-r--r--hw/stellaris.c2
-rw-r--r--hw/stellaris_enet.c2
-rw-r--r--hw/stellaris_input.c4
-rw-r--r--hw/strongarm.c2
-rw-r--r--hw/sun4m.c2
-rw-r--r--hw/sun4u.c6
-rw-r--r--hw/syborg_interrupt.c2
-rw-r--r--hw/syborg_keyboard.c2
-rw-r--r--hw/syborg_pointer.c2
-rw-r--r--hw/syborg_serial.c2
-rw-r--r--hw/sysbus.c4
-rw-r--r--hw/tc58128.c2
-rw-r--r--hw/tc6393xb.c2
-rw-r--r--hw/tsc2005.c2
-rw-r--r--hw/tsc210x.c4
-rw-r--r--hw/tusb6010.c2
-rw-r--r--hw/usb-bus.c4
-rw-r--r--hw/usb-desc.c6
-rw-r--r--hw/usb-ehci.c4
-rw-r--r--hw/usb-musb.c2
-rw-r--r--hw/usb-net.c6
-rw-r--r--hw/usb-uhci.c4
-rw-r--r--hw/vga-isa-mm.c6
-rw-r--r--hw/vga.c8
-rw-r--r--hw/vhost.c16
-rw-r--r--hw/vhost_net.c6
-rw-r--r--hw/virtex_ml507.c6
-rw-r--r--hw/virtio-blk.c6
-rw-r--r--hw/virtio-net.c8
-rw-r--r--hw/virtio-serial-bus.c22
-rw-r--r--hw/virtio.c12
-rw-r--r--hw/vmware_vga.c6
-rw-r--r--hw/wm8750.c2
-rw-r--r--hw/xen_backend.c18
-rw-r--r--hw/xen_console.c6
-rw-r--r--hw/xen_devconfig.c4
-rw-r--r--hw/xen_disk.c24
-rw-r--r--hw/xen_nic.c6
-rw-r--r--hw/xenfb.c10
-rw-r--r--hw/xics.c8
-rw-r--r--hw/xilinx_axienet.c6
-rw-r--r--hw/xilinx_timer.c2
-rw-r--r--input.c12
-rw-r--r--iohandler.c8
-rw-r--r--kvm-all.c20
-rw-r--r--libcacard/cac.c16
-rw-r--r--libcacard/card_7816.c28
-rw-r--r--libcacard/event.c4
-rw-r--r--libcacard/vcard.c20
-rw-r--r--libcacard/vcard_emul_nss.c48
-rw-r--r--libcacard/vreader.c14
-rw-r--r--libcacard/vscclient.c2
-rw-r--r--linux-aio.c4
-rw-r--r--linux-user/elfload.c26
-rw-r--r--linux-user/main.c2
-rw-r--r--linux-user/syscall.c8
-rw-r--r--memory.c22
-rw-r--r--migration-exec.c4
-rw-r--r--migration-fd.c4
-rw-r--r--migration-tcp.c4
-rw-r--r--migration-unix.c4
-rw-r--r--migration.c2
-rw-r--r--module.c2
-rw-r--r--monitor.c44
-rw-r--r--net.c24
-rw-r--r--net/queue.c14
-rw-r--r--net/slirp.c22
-rw-r--r--net/socket.c6
-rw-r--r--os-posix.c4
-rw-r--r--os-win32.c8
-rw-r--r--pflib.c10
-rw-r--r--posix-aio-compat.c2
-rw-r--r--qapi/qapi-dealloc-visitor.c14
-rw-r--r--qapi/qmp-input-visitor.c12
-rw-r--r--qapi/qmp-output-visitor.c10
-rw-r--r--qapi/qmp-registry.c2
-rw-r--r--qbool.c4
-rw-r--r--qdict.c12
-rw-r--r--qemu-char.c84
-rw-r--r--qemu-ga.c2
-rw-r--r--qemu-img.c18
-rw-r--r--qemu-io.c12
-rw-r--r--qemu-nbd.c4
-rw-r--r--qemu-option.c28
-rw-r--r--qemu-sockets.c4
-rw-r--r--qemu-thread-win32.c2
-rw-r--r--qemu-timer.c10
-rw-r--r--qemu-tool.c4
-rw-r--r--qerror.c4
-rw-r--r--qfloat.c4
-rw-r--r--qga/guest-agent-command-state.c4
-rw-r--r--qga/guest-agent-commands.c32
-rw-r--r--qint.c4
-rw-r--r--qlist.c10
-rw-r--r--qstring.c10
-rw-r--r--readline.c8
-rw-r--r--savevm.c58
-rw-r--r--slirp/misc.c2
-rw-r--r--slirp/slirp.c12
-rw-r--r--slirp/tftp.c6
-rw-r--r--spice-qemu-char.c8
-rw-r--r--target-alpha/translate.c2
-rw-r--r--target-arm/helper.c2
-rw-r--r--target-cris/translate.c2
-rw-r--r--target-i386/cpuid.c2
-rw-r--r--target-i386/helper.c4
-rw-r--r--target-i386/kvm.c20
-rw-r--r--target-lm32/helper.c2
-rw-r--r--target-m68k/helper.c4
-rw-r--r--target-microblaze/translate.c2
-rw-r--r--target-mips/translate.c2
-rw-r--r--target-mips/translate_init.c4
-rw-r--r--target-ppc/helper.c4
-rw-r--r--target-ppc/kvm_ppc.c2
-rw-r--r--target-ppc/translate_init.c6
-rw-r--r--target-s390x/helper.c2
-rw-r--r--target-sh4/translate.c2
-rw-r--r--target-sparc/helper.c4
-rw-r--r--target-unicore32/helper.c2
-rw-r--r--tcg/tcg.c8
-rw-r--r--test-qmp-commands.c6
-rw-r--r--test-visitor.c12
-rw-r--r--tests/qruncom.c8
-rw-r--r--ui/curses.c2
-rw-r--r--ui/keymaps.c6
-rw-r--r--ui/sdl.c20
-rw-r--r--ui/spice-core.c30
-rw-r--r--ui/spice-display.c12
-rw-r--r--ui/spice-input.c4
-rw-r--r--ui/vnc-auth-sasl.c2
-rw-r--r--ui/vnc-enc-hextile.c4
-rw-r--r--ui/vnc-enc-tight.c12
-rw-r--r--ui/vnc-enc-zlib.c4
-rw-r--r--ui/vnc-jobs-async.c14
-rw-r--r--ui/vnc-palette.c4
-rw-r--r--ui/vnc-tls.c18
-rw-r--r--ui/vnc.c54
-rw-r--r--usb-bsd.c2
-rw-r--r--usb-linux.c14
-rw-r--r--usb-redir.c8
-rw-r--r--vl.c44
-rw-r--r--xen-all.c14
-rw-r--r--xen-mapcache.c28
357 files changed, 1672 insertions, 1674 deletions
diff --git a/acl.c b/acl.c
index 82c27043c..0654f38f7 100644
--- a/acl.c
+++ b/acl.c
@@ -55,8 +55,8 @@ qemu_acl *qemu_acl_init(const char *aclname)
if (acl)
return acl;
- acl = qemu_malloc(sizeof(*acl));
- acl->aclname = qemu_strdup(aclname);
+ acl = g_malloc(sizeof(*acl));
+ acl->aclname = g_strdup(aclname);
/* Deny by default, so there is no window of "open
* access" between QEMU starting, and the user setting
* up ACLs in the monitor */
@@ -65,7 +65,7 @@ qemu_acl *qemu_acl_init(const char *aclname)
acl->nentries = 0;
QTAILQ_INIT(&acl->entries);
- acls = qemu_realloc(acls, sizeof(*acls) * (nacls +1));
+ acls = g_realloc(acls, sizeof(*acls) * (nacls +1));
acls[nacls] = acl;
nacls++;
@@ -116,8 +116,8 @@ int qemu_acl_append(qemu_acl *acl,
{
qemu_acl_entry *entry;
- entry = qemu_malloc(sizeof(*entry));
- entry->match = qemu_strdup(match);
+ entry = g_malloc(sizeof(*entry));
+ entry->match = g_strdup(match);
entry->deny = deny;
QTAILQ_INSERT_TAIL(&acl->entries, entry, next);
@@ -142,8 +142,8 @@ int qemu_acl_insert(qemu_acl *acl,
return qemu_acl_append(acl, deny, match);
- entry = qemu_malloc(sizeof(*entry));
- entry->match = qemu_strdup(match);
+ entry = g_malloc(sizeof(*entry));
+ entry->match = g_strdup(match);
entry->deny = deny;
QTAILQ_FOREACH(tmp, &acl->entries, next) {
diff --git a/aio.c b/aio.c
index 2f086557b..1239ca7bd 100644
--- a/aio.c
+++ b/aio.c
@@ -75,13 +75,13 @@ int qemu_aio_set_fd_handler(int fd,
* releasing the walking_handlers lock.
*/
QLIST_REMOVE(node, node);
- qemu_free(node);
+ g_free(node);
}
}
} else {
if (node == NULL) {
/* Alloc and insert if it's not already there */
- node = qemu_mallocz(sizeof(AioHandler));
+ node = g_malloc0(sizeof(AioHandler));
node->fd = fd;
QLIST_INSERT_HEAD(&aio_handlers, node, node);
}
@@ -220,7 +220,7 @@ void qemu_aio_wait(void)
if (tmp->deleted) {
QLIST_REMOVE(tmp, node);
- qemu_free(tmp);
+ g_free(tmp);
}
}
diff --git a/arch_init.c b/arch_init.c
index 484b39d4d..567ab3281 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -235,7 +235,7 @@ static void sort_ram_list(void)
QLIST_FOREACH(block, &ram_list.blocks, next) {
++n;
}
- blocks = qemu_malloc(n * sizeof *blocks);
+ blocks = g_malloc(n * sizeof *blocks);
n = 0;
QLIST_FOREACH_SAFE(block, &ram_list.blocks, next, nblock) {
blocks[n++] = block;
@@ -245,7 +245,7 @@ static void sort_ram_list(void)
while (--n >= 0) {
QLIST_INSERT_HEAD(&ram_list.blocks, blocks[n], next);
}
- qemu_free(blocks);
+ g_free(blocks);
}
int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
diff --git a/async.c b/async.c
index 3fe70b9de..9d4e960b0 100644
--- a/async.c
+++ b/async.c
@@ -43,7 +43,7 @@ struct QEMUBH {
QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque)
{
QEMUBH *bh;
- bh = qemu_mallocz(sizeof(QEMUBH));
+ bh = g_malloc0(sizeof(QEMUBH));
bh->cb = cb;
bh->opaque = opaque;
bh->next = first_bh;
@@ -74,7 +74,7 @@ int qemu_bh_poll(void)
bh = *bhp;
if (bh->deleted) {
*bhp = bh->next;
- qemu_free(bh);
+ g_free(bh);
} else
bhp = &bh->next;
}
diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index 4d720146d..cb45b49c2 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -136,7 +136,7 @@ static void alsa_fini_poll (struct pollhlp *hlp)
for (i = 0; i < hlp->count; ++i) {
qemu_set_fd_handler (pfds[i].fd, NULL, NULL, NULL);
}
- qemu_free (pfds);
+ g_free (pfds);
}
hlp->pfds = NULL;
hlp->count = 0;
@@ -260,7 +260,7 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask)
if (err < 0) {
alsa_logerr (err, "Could not initialize poll mode\n"
"Could not obtain poll descriptors\n");
- qemu_free (pfds);
+ g_free (pfds);
return -1;
}
@@ -288,7 +288,7 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask)
while (i--) {
qemu_set_fd_handler (pfds[i].fd, NULL, NULL, NULL);
}
- qemu_free (pfds);
+ g_free (pfds);
return -1;
}
}
@@ -816,7 +816,7 @@ static void alsa_fini_out (HWVoiceOut *hw)
alsa_anal_close (&alsa->handle, &alsa->pollhlp);
if (alsa->pcm_buf) {
- qemu_free (alsa->pcm_buf);
+ g_free (alsa->pcm_buf);
alsa->pcm_buf = NULL;
}
}
@@ -979,7 +979,7 @@ static void alsa_fini_in (HWVoiceIn *hw)
alsa_anal_close (&alsa->handle, &alsa->pollhlp);
if (alsa->pcm_buf) {
- qemu_free (alsa->pcm_buf);
+ g_free (alsa->pcm_buf);
alsa->pcm_buf = NULL;
}
}
diff --git a/audio/audio.c b/audio/audio.c
index 50d2b6438..5649075b0 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -196,7 +196,7 @@ void *audio_calloc (const char *funcname, int nmemb, size_t size)
return NULL;
}
- return qemu_mallocz (len);
+ return g_malloc0 (len);
}
static char *audio_alloc_prefix (const char *s)
@@ -210,7 +210,7 @@ static char *audio_alloc_prefix (const char *s)
}
len = strlen (s);
- r = qemu_malloc (len + sizeof (qemu_prefix));
+ r = g_malloc (len + sizeof (qemu_prefix));
u = r + sizeof (qemu_prefix) - 1;
@@ -425,7 +425,7 @@ static void audio_print_options (const char *prefix,
printf (" %s\n", opt->descr);
}
- qemu_free (uprefix);
+ g_free (uprefix);
}
static void audio_process_options (const char *prefix,
@@ -462,7 +462,7 @@ static void audio_process_options (const char *prefix,
* (includes trailing zero) + zero + underscore (on behalf of
* sizeof) */
optlen = len + preflen + sizeof (qemu_prefix) + 1;
- optname = qemu_malloc (optlen);
+ optname = g_malloc (optlen);
pstrcpy (optname, optlen, qemu_prefix);
@@ -507,7 +507,7 @@ static void audio_process_options (const char *prefix,
opt->overriddenp = &opt->overridden;
}
*opt->overriddenp = !def;
- qemu_free (optname);
+ g_free (optname);
}
}
@@ -778,7 +778,7 @@ static void audio_detach_capture (HWVoiceOut *hw)
QLIST_REMOVE (sw, entries);
QLIST_REMOVE (sc, entries);
- qemu_free (sc);
+ g_free (sc);
if (was_active) {
/* We have removed soft voice from the capture:
this might have changed the overall status of the capture
@@ -818,7 +818,7 @@ static int audio_attach_capture (HWVoiceOut *hw)
sw->rate = st_rate_start (sw->info.freq, hw_cap->info.freq);
if (!sw->rate) {
dolog ("Could not start rate conversion for `%s'\n", SW_NAME (sw));
- qemu_free (sw);
+ g_free (sw);
return -1;
}
QLIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries);
@@ -1907,7 +1907,7 @@ static void audio_init (void)
void AUD_register_card (const char *name, QEMUSoundCard *card)
{
audio_init ();
- card->name = qemu_strdup (name);
+ card->name = g_strdup (name);
memset (&card->entries, 0, sizeof (card->entries));
QLIST_INSERT_HEAD (&glob_audio_state.card_head, card, entries);
}
@@ -1915,7 +1915,7 @@ void AUD_register_card (const char *name, QEMUSoundCard *card)
void AUD_remove_card (QEMUSoundCard *card)
{
QLIST_REMOVE (card, entries);
- qemu_free (card->name);
+ g_free (card->name);
}
@@ -2000,11 +2000,11 @@ CaptureVoiceOut *AUD_add_capture (
return cap;
err3:
- qemu_free (cap->hw.mix_buf);
+ g_free (cap->hw.mix_buf);
err2:
- qemu_free (cap);
+ g_free (cap);
err1:
- qemu_free (cb);
+ g_free (cb);
err0:
return NULL;
}
@@ -2018,7 +2018,7 @@ void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque)
if (cb->opaque == cb_opaque) {
cb->ops.destroy (cb_opaque);
QLIST_REMOVE (cb, entries);
- qemu_free (cb);
+ g_free (cb);
if (!cap->cb_head.lh_first) {
SWVoiceOut *sw = cap->hw.sw_head.lh_first, *sw1;
@@ -2036,11 +2036,11 @@ void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque)
}
QLIST_REMOVE (sw, entries);
QLIST_REMOVE (sc, entries);
- qemu_free (sc);
+ g_free (sc);
sw = sw1;
}
QLIST_REMOVE (cap, entries);
- qemu_free (cap);
+ g_free (cap);
}
return;
}
diff --git a/audio/audio_template.h b/audio/audio_template.h
index fd4469e63..e62a71345 100644
--- a/audio/audio_template.h
+++ b/audio/audio_template.h
@@ -72,7 +72,7 @@ static void glue (audio_init_nb_voices_, TYPE) (struct audio_driver *drv)
static void glue (audio_pcm_hw_free_resources_, TYPE) (HW *hw)
{
if (HWBUF) {
- qemu_free (HWBUF);
+ g_free (HWBUF);
}
HWBUF = NULL;
@@ -93,7 +93,7 @@ static int glue (audio_pcm_hw_alloc_resources_, TYPE) (HW *hw)
static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw)
{
if (sw->buf) {
- qemu_free (sw->buf);
+ g_free (sw->buf);
}
if (sw->rate) {
@@ -123,7 +123,7 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) (SW *sw)
sw->rate = st_rate_start (sw->hw->info.freq, sw->info.freq);
#endif
if (!sw->rate) {
- qemu_free (sw->buf);
+ g_free (sw->buf);
sw->buf = NULL;
return -1;
}
@@ -160,10 +160,10 @@ static int glue (audio_pcm_sw_init_, TYPE) (
[sw->info.swap_endianness]
[audio_bits_to_index (sw->info.bits)];
- sw->name = qemu_strdup (name);
+ sw->name = g_strdup (name);
err = glue (audio_pcm_sw_alloc_resources_, TYPE) (sw);
if (err) {
- qemu_free (sw->name);
+ g_free (sw->name);
sw->name = NULL;
}
return err;
@@ -173,7 +173,7 @@ static void glue (audio_pcm_sw_fini_, TYPE) (SW *sw)
{
glue (audio_pcm_sw_free_resources_, TYPE) (sw);
if (sw->name) {
- qemu_free (sw->name);
+ g_free (sw->name);
sw->name = NULL;
}
}
@@ -201,7 +201,7 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp)
glue (s->nb_hw_voices_, TYPE) += 1;
glue (audio_pcm_hw_free_resources_ ,TYPE) (hw);
glue (hw->pcm_ops->fini_, TYPE) (hw);
- qemu_free (hw);
+ g_free (hw);
*hwp = NULL;
}
}
@@ -300,7 +300,7 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as)
err1:
glue (hw->pcm_ops->fini_, TYPE) (hw);
err0:
- qemu_free (hw);
+ g_free (hw);
return NULL;
}
@@ -368,7 +368,7 @@ err3:
glue (audio_pcm_hw_del_sw_, TYPE) (sw);
glue (audio_pcm_hw_gc_, TYPE) (&hw);
err2:
- qemu_free (sw);
+ g_free (sw);
err1:
return NULL;
}
@@ -378,7 +378,7 @@ static void glue (audio_close_, TYPE) (SW *sw)
glue (audio_pcm_sw_fini_, TYPE) (sw);
glue (audio_pcm_hw_del_sw_, TYPE) (sw);
glue (audio_pcm_hw_gc_, TYPE) (&sw->hw);
- qemu_free (sw);
+ g_free (sw);
}
void glue (AUD_close_, TYPE) (QEMUSoundCard *card, SW *sw)
diff --git a/audio/esdaudio.c b/audio/esdaudio.c
index ff97b397d..bd6e1cc19 100644
--- a/audio/esdaudio.c
+++ b/audio/esdaudio.c
@@ -246,7 +246,7 @@ static int qesd_init_out (HWVoiceOut *hw, struct audsettings *as)
esd->fd = -1;
fail1:
- qemu_free (esd->pcm_buf);
+ g_free (esd->pcm_buf);
esd->pcm_buf = NULL;
return -1;
}
@@ -270,7 +270,7 @@ static void qesd_fini_out (HWVoiceOut *hw)
audio_pt_fini (&esd->pt, AUDIO_FUNC);
- qemu_free (esd->pcm_buf);
+ g_free (esd->pcm_buf);
esd->pcm_buf = NULL;
}
@@ -453,7 +453,7 @@ static int qesd_init_in (HWVoiceIn *hw, struct audsettings *as)
esd->fd = -1;
fail1:
- qemu_free (esd->pcm_buf);
+ g_free (esd->pcm_buf);
esd->pcm_buf = NULL;
return -1;
}
@@ -477,7 +477,7 @@ static void qesd_fini_in (HWVoiceIn *hw)
audio_pt_fini (&esd->pt, AUDIO_FUNC);
- qemu_free (esd->pcm_buf);
+ g_free (esd->pcm_buf);
esd->pcm_buf = NULL;
}
diff --git a/audio/mixeng.c b/audio/mixeng.c
index 4a9e8ebe2..5446be674 100644
--- a/audio/mixeng.c
+++ b/audio/mixeng.c
@@ -326,7 +326,7 @@ void *st_rate_start (int inrate, int outrate)
void st_rate_stop (void *opaque)
{
- qemu_free (opaque);
+ g_free (opaque);
}
void mixeng_clear (struct st_sample *buf, int len)
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index b49e10274..df51b7cc5 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -508,7 +508,7 @@ static void oss_fini_out (HWVoiceOut *hw)
}
}
else {
- qemu_free (oss->pcm_buf);
+ g_free (oss->pcm_buf);
}
oss->pcm_buf = NULL;
}
@@ -741,7 +741,7 @@ static void oss_fini_in (HWVoiceIn *hw)
oss_anal_close (&oss->fd);
if (oss->pcm_buf) {
- qemu_free (oss->pcm_buf);
+ g_free (oss->pcm_buf);
oss->pcm_buf = NULL;
}
}
diff --git a/audio/paaudio.c b/audio/paaudio.c
index fb4510e42..d1f3912ce 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -339,7 +339,7 @@ static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as)
return 0;
fail3:
- qemu_free (pa->pcm_buf);
+ g_free (pa->pcm_buf);
pa->pcm_buf = NULL;
fail2:
pa_simple_free (pa->s);
@@ -394,7 +394,7 @@ static int qpa_init_in (HWVoiceIn *hw, struct audsettings *as)
return 0;
fail3:
- qemu_free (pa->pcm_buf);
+ g_free (pa->pcm_buf);
pa->pcm_buf = NULL;
fail2:
pa_simple_free (pa->s);
@@ -419,7 +419,7 @@ static void qpa_fini_out (HWVoiceOut *hw)
}
audio_pt_fini (&pa->pt, AUDIO_FUNC);
- qemu_free (pa->pcm_buf);
+ g_free (pa->pcm_buf);
pa->pcm_buf = NULL;
}
@@ -439,7 +439,7 @@ static void qpa_fini_in (HWVoiceIn *hw)
}
audio_pt_fini (&pa->pt, AUDIO_FUNC);
- qemu_free (pa->pcm_buf);
+ g_free (pa->pcm_buf);
pa->pcm_buf = NULL;
}
diff --git a/audio/wavaudio.c b/audio/wavaudio.c
index 294f35704..aed18176e 100644
--- a/audio/wavaudio.c
+++ b/audio/wavaudio.c
@@ -156,7 +156,7 @@ static int wav_init_out (HWVoiceOut *hw, struct audsettings *as)
if (!wav->f) {
dolog ("Failed to open wave file `%s'\nReason: %s\n",
conf.wav_path, strerror (errno));
- qemu_free (wav->pcm_buf);
+ g_free (wav->pcm_buf);
wav->pcm_buf = NULL;
return -1;
}
@@ -189,7 +189,7 @@ static void wav_fini_out (HWVoiceOut *hw)
qemu_fclose (wav->f);
wav->f = NULL;
- qemu_free (wav->pcm_buf);
+ g_free (wav->pcm_buf);
wav->pcm_buf = NULL;
}
diff --git a/audio/wavcapture.c b/audio/wavcapture.c
index 1f49cd1fe..c64f0ef07 100644
--- a/audio/wavcapture.c
+++ b/audio/wavcapture.c
@@ -48,7 +48,7 @@ static void wav_destroy (void *opaque)
qemu_fclose (wav->f);
}
- qemu_free (wav->path);
+ g_free (wav->path);
}
static void wav_capture (void *opaque, void *buf, int size)
@@ -120,7 +120,7 @@ int wav_start_capture (CaptureState *s, const char *path, int freq,
ops.capture = wav_capture;
ops.destroy = wav_destroy;
- wav = qemu_mallocz (sizeof (*wav));
+ wav = g_malloc0 (sizeof (*wav));
shift = bits16 + stereo;
hdr[34] = bits16 ? 0x10 : 0x08;
@@ -134,11 +134,11 @@ int wav_start_capture (CaptureState *s, const char *path, int freq,
if (!wav->f) {
monitor_printf(mon, "Failed to open wave file `%s'\nReason: %s\n",
path, strerror (errno));
- qemu_free (wav);
+ g_free (wav);
return -1;
}
- wav->path = qemu_strdup (path);
+ wav->path = g_strdup (path);
wav->bits = bits;
wav->nchannels = nchannels;
wav->freq = freq;
@@ -148,9 +148,9 @@ int wav_start_capture (CaptureState *s, const char *path, int freq,
cap = AUD_add_capture (&as, &ops, wav);
if (!cap) {
monitor_printf(mon, "Failed to add audio capture\n");
- qemu_free (wav->path);
+ g_free (wav->path);
qemu_fclose (wav->f);
- qemu_free (wav);
+ g_free (wav);
return -1;
}
diff --git a/audio/winwaveaudio.c b/audio/winwaveaudio.c
index e5ad3c660..87e749327 100644
--- a/audio/winwaveaudio.c
+++ b/audio/winwaveaudio.c
@@ -222,9 +222,9 @@ static int winwave_init_out (HWVoiceOut *hw, struct audsettings *as)
return 0;
err4:
- qemu_free (wave->pcm_buf);
+ g_free (wave->pcm_buf);
err3:
- qemu_free (wave->hdrs);
+ g_free (wave->hdrs);
err2:
winwave_anal_close_out (wave);
err1:
@@ -310,10 +310,10 @@ static void winwave_fini_out (HWVoiceOut *hw)
wave->event = NULL;
}
- qemu_free (wave->pcm_buf);
+ g_free (wave->pcm_buf);
wave->pcm_buf = NULL;
- qemu_free (wave->hdrs);
+ g_free (wave->hdrs);
wave->hdrs = NULL;
}
@@ -511,9 +511,9 @@ static int winwave_init_in (HWVoiceIn *hw, struct audsettings *as)
return 0;
err4:
- qemu_free (wave->pcm_buf);
+ g_free (wave->pcm_buf);
err3:
- qemu_free (wave->hdrs);
+ g_free (wave->hdrs);
err2:
winwave_anal_close_in (wave);
err1:
@@ -550,10 +550,10 @@ static void winwave_fini_in (HWVoiceIn *hw)
wave->event = NULL;
}
- qemu_free (wave->pcm_buf);
+ g_free (wave->pcm_buf);
wave->pcm_buf = NULL;
- qemu_free (wave->hdrs);
+ g_free (wave->hdrs);
wave->hdrs = NULL;
}
diff --git a/bitmap.h b/bitmap.h
index efd5d3a1e..08755eba1 100644
--- a/bitmap.h
+++ b/bitmap.h
@@ -91,7 +91,7 @@ int slow_bitmap_intersects(const unsigned long *bitmap1,
static inline unsigned long *bitmap_new(int nbits)
{
int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
- return qemu_mallocz(len);
+ return g_malloc0(len);
}
static inline void bitmap_zero(unsigned long *dst, int nbits)
diff --git a/block-migration.c b/block-migration.c
index 0936c7d5e..e2775ee50 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -180,7 +180,7 @@ static void alloc_aio_bitmap(BlkMigDevState *bmds)
BDRV_SECTORS_PER_DIRTY_CHUNK * 8 - 1;
bitmap_size /= BDRV_SECTORS_PER_DIRTY_CHUNK * 8;
- bmds->aio_bitmap = qemu_mallocz(bitmap_size);
+ bmds->aio_bitmap = g_malloc0(bitmap_size);
}
static void blk_mig_read_cb(void *opaque, int ret)
@@ -235,8 +235,8 @@ static int mig_save_device_bulk(Monitor *mon, QEMUFile *f,
nr_sectors = total_sectors - cur_sector;
}
- blk = qemu_malloc(sizeof(BlkMigBlock));
- blk->buf = qemu_malloc(BLOCK_SIZE);
+ blk = g_malloc(sizeof(BlkMigBlock));
+ blk->buf = g_malloc(BLOCK_SIZE);
blk->bmds = bmds;
blk->sector = cur_sector;
blk->nr_sectors = nr_sectors;
@@ -264,8 +264,8 @@ static int mig_save_device_bulk(Monitor *mon, QEMUFile *f,
error:
monitor_printf(mon, "Error reading sector %" PRId64 "\n", cur_sector);
qemu_file_set_error(f);
- qemu_free(blk->buf);
- qemu_free(blk);
+ g_free(blk->buf);
+ g_free(blk);
return 0;
}
@@ -290,7 +290,7 @@ static void init_blk_migration_it(void *opaque, BlockDriverState *bs)
return;
}
- bmds = qemu_mallocz(sizeof(BlkMigDevState));
+ bmds = g_malloc0(sizeof(BlkMigDevState));
bmds->bs = bs;
bmds->bulk_completed = 0;
bmds->total_sectors = sectors;
@@ -395,8 +395,8 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f,
} else {
nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
}
- blk = qemu_malloc(sizeof(BlkMigBlock));
- blk->buf = qemu_malloc(BLOCK_SIZE);
+ blk = g_malloc(sizeof(BlkMigBlock));
+ blk->buf = g_malloc(BLOCK_SIZE);
blk->bmds = bmds;
blk->sector = sector;
blk->nr_sectors = nr_sectors;
@@ -424,8 +424,8 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f,
}
blk_send(f, blk);
- qemu_free(blk->buf);
- qemu_free(blk);
+ g_free(blk->buf);
+ g_free(blk);
}
bdrv_reset_dirty(bmds->bs, sector, nr_sectors);
@@ -440,8 +440,8 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f,
error:
monitor_printf(mon, "Error reading sector %" PRId64 "\n", sector);
qemu_file_set_error(f);
- qemu_free(blk->buf);
- qemu_free(blk);
+ g_free(blk->buf);
+ g_free(blk);
return 0;
}
@@ -479,8 +479,8 @@ static void flush_blks(QEMUFile* f)
blk_send(f, blk);
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
- qemu_free(blk->buf);
- qemu_free(blk);
+ g_free(blk->buf);
+ g_free(blk);
block_mig_state.read_done--;
block_mig_state.transferred++;
@@ -541,14 +541,14 @@ static void blk_mig_cleanup(Monitor *mon)
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);
bdrv_set_in_use(bmds->bs, 0);
drive_put_ref(drive_get_by_blockdev(bmds->bs));
- qemu_free(bmds->aio_bitmap);
- qemu_free(bmds);
+ g_free(bmds->aio_bitmap);
+ g_free(bmds);
}
while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
- qemu_free(blk->buf);
- qemu_free(blk);
+ g_free(blk->buf);
+ g_free(blk);
}
monitor_printf(mon, "\n");
@@ -683,12 +683,12 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
}
- buf = qemu_malloc(BLOCK_SIZE);
+ buf = g_malloc(BLOCK_SIZE);
qemu_get_buffer(f, buf, BLOCK_SIZE);
ret = bdrv_write(bs, addr, buf, nr_sectors);
- qemu_free(buf);
+ g_free(buf);
if (ret < 0) {
return ret;
}
diff --git a/block.c b/block.c
index 26910ca14..785c88e17 100644
--- a/block.c
+++ b/block.c
@@ -215,7 +215,7 @@ BlockDriverState *bdrv_new(const char *device_name)
{
BlockDriverState *bs;
- bs = qemu_mallocz(sizeof(BlockDriverState));
+ bs = g_malloc0(sizeof(BlockDriverState));
pstrcpy(bs->device_name, sizeof(bs->device_name), device_name);
if (device_name[0] != '\0') {
QTAILQ_INSERT_TAIL(&bdrv_states, bs, list);
@@ -462,7 +462,7 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename,
}
bs->drv = drv;
- bs->opaque = qemu_mallocz(drv->instance_size);
+ bs->opaque = g_malloc0(drv->instance_size);
if (flags & BDRV_O_CACHE_WB)
bs->enable_write_cache = 1;
@@ -513,7 +513,7 @@ free_and_fail:
bdrv_delete(bs->file);
bs->file = NULL;
}
- qemu_free(bs->opaque);
+ g_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
return ret;
@@ -687,7 +687,7 @@ void bdrv_close(BlockDriverState *bs)
bs->backing_hd = NULL;
}
bs->drv->bdrv_close(bs);
- qemu_free(bs->opaque);
+ g_free(bs->opaque);
#ifdef _WIN32
if (bs->is_temporary) {
unlink(bs->filename);
@@ -739,7 +739,7 @@ void bdrv_delete(BlockDriverState *bs)
}
assert(bs != bs_snapshots);
- qemu_free(bs);
+ g_free(bs);
}
int bdrv_attach(BlockDriverState *bs, DeviceState *qdev)
@@ -837,7 +837,7 @@ int bdrv_commit(BlockDriverState *bs)
}
total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
- buf = qemu_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE);
+ buf = g_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE);
for (sector = 0; sector < total_sectors; sector += n) {
if (drv->bdrv_is_allocated(bs, sector, COMMIT_BUF_SECTORS, &n)) {
@@ -867,7 +867,7 @@ int bdrv_commit(BlockDriverState *bs)
bdrv_flush(bs->backing_hd);
ro_cleanup:
- qemu_free(buf);
+ g_free(buf);
if (ro) {
/* re-open as RO */
@@ -2275,7 +2275,7 @@ static void block_complete_cb(void *opaque, int ret)
set_dirty_bitmap(b->bs, b->sector_num, b->nb_sectors, 1);
}
b->cb(b->opaque, ret);
- qemu_free(b);
+ g_free(b);
}
static BlockCompleteData *blk_dirty_cb_alloc(BlockDriverState *bs,
@@ -2284,7 +2284,7 @@ static BlockCompleteData *blk_dirty_cb_alloc(BlockDriverState *bs,
BlockDriverCompletionFunc *cb,
void *opaque)
{
- BlockCompleteData *blkdata = qemu_mallocz(sizeof(BlockCompleteData));
+ BlockCompleteData *blkdata = g_malloc0(sizeof(BlockCompleteData));
blkdata->bs = bs;
blkdata->cb = cb;
@@ -2356,7 +2356,7 @@ static void multiwrite_user_cb(MultiwriteCB *mcb)
if (mcb->callbacks[i].free_qiov) {
qemu_iovec_destroy(mcb->callbacks[i].free_qiov);
}
- qemu_free(mcb->callbacks[i].free_qiov);
+ g_free(mcb->callbacks[i].free_qiov);
qemu_vfree(mcb->callbacks[i].free_buf);
}
}
@@ -2374,7 +2374,7 @@ static void multiwrite_cb(void *opaque, int ret)
mcb->num_requests--;
if (mcb->num_requests == 0) {
multiwrite_user_cb(mcb);
- qemu_free(mcb);
+ g_free(mcb);
}
}
@@ -2434,7 +2434,7 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs,
if (merge) {
size_t size;
- QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov));
+ QEMUIOVector *qiov = g_malloc0(sizeof(*qiov));
qemu_iovec_init(qiov,
reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1);
@@ -2503,7 +2503,7 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)
}
// Create MultiwriteCB structure
- mcb = qemu_mallocz(sizeof(*mcb) + num_reqs * sizeof(*mcb->callbacks));
+ mcb = g_malloc0(sizeof(*mcb) + num_reqs * sizeof(*mcb->callbacks));
mcb->num_requests = 0;
mcb->num_callbacks = num_reqs;
@@ -2568,7 +2568,7 @@ fail:
for (i = 0; i < mcb->num_callbacks; i++) {
reqs[i].error = -EIO;
}
- qemu_free(mcb);
+ g_free(mcb);
return -1;
}
@@ -2884,7 +2884,7 @@ void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs,
acb = pool->free_aiocb;
pool->free_aiocb = acb->next;
} else {
- acb = qemu_mallocz(pool->aiocb_size);
+ acb = g_malloc0(pool->aiocb_size);
acb->pool = pool;
}
acb->bs = bs;
@@ -3088,11 +3088,11 @@ void bdrv_set_dirty_tracking(BlockDriverState *bs, int enable)
BDRV_SECTORS_PER_DIRTY_CHUNK * 8 - 1;
bitmap_size /= BDRV_SECTORS_PER_DIRTY_CHUNK * 8;
- bs->dirty_bitmap = qemu_mallocz(bitmap_size);
+ bs->dirty_bitmap = g_malloc0(bitmap_size);
}
} else {
if (bs->dirty_bitmap) {
- qemu_free(bs->dirty_bitmap);
+ g_free(bs->dirty_bitmap);
bs->dirty_bitmap = NULL;
}
}
diff --git a/block/blkdebug.c b/block/blkdebug.c
index cd9eb8006..b3c5d42ce 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -214,7 +214,7 @@ static int add_rule(QemuOpts *opts, void *opaque)
}
/* Set attributes common for all actions */
- rule = qemu_mallocz(sizeof(*rule));
+ rule = g_malloc0(sizeof(*rule));
*rule = (struct BlkdebugRule) {
.event = event,
.action = d->action,
@@ -392,7 +392,7 @@ static void blkdebug_close(BlockDriverState *bs)
for (i = 0; i < BLKDBG_EVENT_MAX; i++) {
QLIST_FOREACH_SAFE(rule, &s->rules[i], next, next) {
QLIST_REMOVE(rule, next);
- qemu_free(rule);
+ g_free(rule);
}
}
}
diff --git a/block/bochs.c b/block/bochs.c
index 5fe2fa358..3c2f8d1b1 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -136,7 +136,7 @@ static int bochs_open(BlockDriverState *bs, int flags)
}
s->catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);
- s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
+ s->catalog_bitmap = g_malloc(s->catalog_size * 4);
if (bdrv_pread(bs->file, le32_to_cpu(bochs.header), s->catalog_bitmap,
s->catalog_size * 4) != s->catalog_size * 4)
goto fail;
@@ -210,7 +210,7 @@ static int bochs_read(BlockDriverState *bs, int64_t sector_num,
static void bochs_close(BlockDriverState *bs)
{
BDRVBochsState *s = bs->opaque;
- qemu_free(s->catalog_bitmap);
+ g_free(s->catalog_bitmap);
}
static BlockDriver bdrv_bochs = {
diff --git a/block/cloop.c b/block/cloop.c
index fe015c425..8cff9f2ca 100644
--- a/block/cloop.c
+++ b/block/cloop.c
@@ -70,7 +70,7 @@ static int cloop_open(BlockDriverState *bs, int flags)
/* read offsets */
offsets_size = s->n_blocks * sizeof(uint64_t);
- s->offsets = qemu_malloc(offsets_size);
+ s->offsets = g_malloc(offsets_size);
if (bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size) <
offsets_size) {
goto cloop_close;
@@ -85,8 +85,8 @@ static int cloop_open(BlockDriverState *bs, int flags)
}
/* initialize zlib engine */
- s->compressed_block = qemu_malloc(max_compressed_block_size+1);
- s->uncompressed_block = qemu_malloc(s->block_size);
+ s->compressed_block = g_malloc(max_compressed_block_size+1);
+ s->uncompressed_block = g_malloc(s->block_size);
if(inflateInit(&s->zstream) != Z_OK)
goto cloop_close;
s->current_block=s->n_blocks;
diff --git a/block/curl.c b/block/curl.c
index 407f0955a..5c157bc60 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -310,7 +310,7 @@ static int curl_open(BlockDriverState *bs, const char *filename, int flags)
static int inited = 0;
- file = qemu_strdup(filename);
+ file = g_strdup(filename);
s->readahead_size = READ_AHEAD_SIZE;
/* Parse a trailing ":readahead=#:" param, if present. */
@@ -390,7 +390,7 @@ out:
curl_easy_cleanup(state->curl);
state->curl = NULL;
out_noclean:
- qemu_free(file);
+ g_free(file);
return -EINVAL;
}
@@ -444,11 +444,11 @@ static BlockDriverAIOCB *curl_aio_readv(BlockDriverState *bs,
state->buf_off = 0;
if (state->orig_buf)
- qemu_free(state->orig_buf);
+ g_free(state->orig_buf);
state->buf_start = start;
state->buf_len = acb->end + s->readahead_size;
end = MIN(start + state->buf_len, s->len) - 1;
- state->orig_buf = qemu_malloc(state->buf_len);
+ state->orig_buf = g_malloc(state->buf_len);
state->acb[0] = acb;
snprintf(state->range, 127, "%zd-%zd", start, end);
@@ -476,7 +476,7 @@ static void curl_close(BlockDriverState *bs)
s->states[i].curl = NULL;
}
if (s->states[i].orig_buf) {
- qemu_free(s->states[i].orig_buf);
+ g_free(s->states[i].orig_buf);
s->states[i].orig_buf = NULL;
}
}
diff --git a/block/dmg.c b/block/dmg.c
index a3c815b86..64c3cce46 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -127,11 +127,11 @@ static int dmg_open(BlockDriverState *bs, int flags)
chunk_count = (count-204)/40;
new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);
- s->types = qemu_realloc(s->types, new_size/2);
- s->offsets = qemu_realloc(s->offsets, new_size);
- s->lengths = qemu_realloc(s->lengths, new_size);
- s->sectors = qemu_realloc(s->sectors, new_size);
- s->sectorcounts = qemu_realloc(s->sectorcounts, new_size);
+ s->types = g_realloc(s->types, new_size/2);
+ s->offsets = g_realloc(s->offsets, new_size);
+ s->lengths = g_realloc(s->lengths, new_size);
+ s->sectors = g_realloc(s->sectors, new_size);
+ s->sectorcounts = g_realloc(s->sectorcounts, new_size);
for(i=s->n_chunks;i<s->n_chunks+chunk_count;i++) {
s->types[i] = read_uint32(bs, offset);
@@ -170,8 +170,8 @@ static int dmg_open(BlockDriverState *bs, int flags)
}
/* initialize zlib engine */
- s->compressed_chunk = qemu_malloc(max_compressed_size+1);
- s->uncompressed_chunk = qemu_malloc(512*max_sectors_per_chunk);
+ s->compressed_chunk = g_malloc(max_compressed_size+1);
+ s->uncompressed_chunk = g_malloc(512*max_sectors_per_chunk);
if(inflateInit(&s->zstream) != Z_OK)
goto fail;
diff --git a/block/nbd.c b/block/nbd.c
index 7a52f62e7..55cb2fd8b 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -65,7 +65,7 @@ static int nbd_config(BDRVNBDState *s, const char *filename, int flags)
const char *unixpath;
int err = -EINVAL;
- file = qemu_strdup(filename);
+ file = g_strdup(filename);
export_name = strstr(file, EN_OPTSTR);
if (export_name) {
@@ -74,7 +74,7 @@ static int nbd_config(BDRVNBDState *s, const char *filename, int flags)
}
export_name[0] = 0; /* truncate 'file' */
export_name += strlen(EN_OPTSTR);
- s->export_name = qemu_strdup(export_name);
+ s->export_name = g_strdup(export_name);
}
/* extract the host_spec - fail if it's not nbd:... */
@@ -87,18 +87,18 @@ static int nbd_config(BDRVNBDState *s, const char *filename, int flags)
if (unixpath[0] != '/') { /* We demand an absolute path*/
goto out;
}
- s->host_spec = qemu_strdup(unixpath);
+ s->host_spec = g_strdup(unixpath);
} else {
- s->host_spec = qemu_strdup(host_spec);
+ s->host_spec = g_strdup(host_spec);
}
err = 0;
out:
- qemu_free(file);
+ g_free(file);
if (err != 0) {
- qemu_free(s->export_name);
- qemu_free(s->host_spec);
+ g_free(s->export_name);
+ g_free(s->host_spec);
}
return err;
}
@@ -240,8 +240,8 @@ static int nbd_write(BlockDriverState *bs, int64_t sector_num,
static void nbd_close(BlockDriverState *bs)
{
BDRVNBDState *s = bs->opaque;
- qemu_free(s->export_name);
- qemu_free(s->host_spec);
+ g_free(s->export_name);
+ g_free(s->host_spec);
nbd_teardown_connection(bs);
}
diff --git a/block/parallels.c b/block/parallels.c
index 35a14aa42..37d151dcb 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -88,7 +88,7 @@ static int parallels_open(BlockDriverState *bs, int flags)
s->tracks = le32_to_cpu(ph.tracks);
s->catalog_size = le32_to_cpu(ph.catalog_entries);
- s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
+ s->catalog_bitmap = g_malloc(s->catalog_size * 4);
if (bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4) !=
s->catalog_size * 4)
goto fail;
@@ -98,7 +98,7 @@ static int parallels_open(BlockDriverState *bs, int flags)
return 0;
fail:
if (s->catalog_bitmap)
- qemu_free(s->catalog_bitmap);
+ g_free(s->catalog_bitmap);
return -1;
}
@@ -137,7 +137,7 @@ static int parallels_read(BlockDriverState *bs, int64_t sector_num,
static void parallels_close(BlockDriverState *bs)
{
BDRVParallelsState *s = bs->opaque;
- qemu_free(s->catalog_bitmap);
+ g_free(s->catalog_bitmap);
}
static BlockDriver bdrv_parallels = {
diff --git a/block/qcow.c b/block/qcow.c
index 6447c2a1c..e155d3c00 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -129,7 +129,7 @@ static int qcow_open(BlockDriverState *bs, int flags)
s->l1_size = (header.size + (1LL << shift) - 1) >> shift;
s->l1_table_offset = header.l1_table_offset;
- s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
+ s->l1_table = g_malloc(s->l1_size * sizeof(uint64_t));
if (!s->l1_table)
goto fail;
if (bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)) !=
@@ -139,13 +139,13 @@ static int qcow_open(BlockDriverState *bs, int flags)
be64_to_cpus(&s->l1_table[i]);
}
/* alloc L2 cache */
- s->l2_cache = qemu_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
+ s->l2_cache = g_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
if (!s->l2_cache)
goto fail;
- s->cluster_cache = qemu_malloc(s->cluster_size);
+ s->cluster_cache = g_malloc(s->cluster_size);
if (!s->cluster_cache)
goto fail;
- s->cluster_data = qemu_malloc(s->cluster_size);
+ s->cluster_data = g_malloc(s->cluster_size);
if (!s->cluster_data)
goto fail;
s->cluster_cache_offset = -1;
@@ -162,10 +162,10 @@ static int qcow_open(BlockDriverState *bs, int flags)
return 0;
fail:
- qemu_free(s->l1_table);
- qemu_free(s->l2_cache);
- qemu_free(s->cluster_cache);
- qemu_free(s->cluster_data);
+ g_free(s->l1_table);
+ g_free(s->l2_cache);
+ g_free(s->cluster_cache);
+ g_free(s->cluster_data);
return -1;
}
@@ -687,7 +687,7 @@ static int qcow_aio_write_cb(void *opaque)
}
if (s->crypt_method) {
if (!acb->cluster_data) {
- acb->cluster_data = qemu_mallocz(s->cluster_size);
+ acb->cluster_data = g_malloc0(s->cluster_size);
}
encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf,
acb->n, 1, &s->aes_encrypt_key);
@@ -738,10 +738,10 @@ static int qcow_co_writev(BlockDriverState *bs, int64_t sector_num,
static void qcow_close(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
- qemu_free(s->l1_table);
- qemu_free(s->l2_cache);
- qemu_free(s->cluster_cache);
- qemu_free(s->cluster_data);
+ g_free(s->l1_table);
+ g_free(s->l2_cache);
+ g_free(s->cluster_cache);
+ g_free(s->cluster_data);
}
static int qcow_create(const char *filename, QEMUOptionParameter *options)
@@ -869,7 +869,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
if (nb_sectors != s->cluster_sectors)
return -EINVAL;
- out_buf = qemu_malloc(s->cluster_size + (s->cluster_size / 1000) + 128);
+ out_buf = g_malloc(s->cluster_size + (s->cluster_size / 1000) + 128);
if (!out_buf)
return -1;
@@ -879,7 +879,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
Z_DEFLATED, -12,
9, Z_DEFAULT_STRATEGY);
if (ret != 0) {
- qemu_free(out_buf);
+ g_free(out_buf);
return -1;
}
@@ -890,7 +890,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
ret = deflate(&strm, Z_FINISH);
if (ret != Z_STREAM_END && ret != Z_OK) {
- qemu_free(out_buf);
+ g_free(out_buf);
deflateEnd(&strm);
return -1;
}
@@ -906,12 +906,12 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
out_len, 0, 0);
cluster_offset &= s->cluster_offset_mask;
if (bdrv_pwrite(bs->file, cluster_offset, out_buf, out_len) != out_len) {
- qemu_free(out_buf);
+ g_free(out_buf);
return -1;
}
}
- qemu_free(out_buf);
+ g_free(out_buf);
return 0;
}
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
index 84088477a..340a6f2b2 100644
--- a/block/qcow2-cache.c
+++ b/block/qcow2-cache.c
@@ -49,9 +49,9 @@ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables,
Qcow2Cache *c;
int i;
- c = qemu_mallocz(sizeof(*c));
+ c = g_malloc0(sizeof(*c));
c->size = num_tables;
- c->entries = qemu_mallocz(sizeof(*c->entries) * num_tables);
+ c->entries = g_malloc0(sizeof(*c->entries) * num_tables);
c->writethrough = writethrough;
for (i = 0; i < c->size; i++) {
@@ -70,8 +70,8 @@ int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c)
qemu_vfree(c->entries[i].table);
}
- qemu_free(c->entries);
- qemu_free(c);
+ g_free(c->entries);
+ g_free(c);
return 0;
}
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 81cf77d83..9269ddaef 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -57,14 +57,14 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size, bool exact_size)
#endif
new_l1_size2 = sizeof(uint64_t) * new_l1_size;
- new_l1_table = qemu_mallocz(align_offset(new_l1_size2, 512));
+ new_l1_table = g_malloc0(align_offset(new_l1_size2, 512));
memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t));
/* write new table (align to cluster) */
BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ALLOC_TABLE);
new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2);
if (new_l1_table_offset < 0) {
- qemu_free(new_l1_table);
+ g_free(new_l1_table);
return new_l1_table_offset;
}
@@ -90,14 +90,14 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size, bool exact_size)
if (ret < 0) {
goto fail;
}
- qemu_free(s->l1_table);
+ g_free(s->l1_table);
qcow2_free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t));
s->l1_table_offset = new_l1_table_offset;
s->l1_table = new_l1_table;
s->l1_size = new_l1_size;
return 0;
fail:
- qemu_free(new_l1_table);
+ g_free(new_l1_table);
qcow2_free_clusters(bs, new_l1_table_offset, new_l1_size2);
return ret;
}
@@ -612,7 +612,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
if (m->nb_clusters == 0)
return 0;
- old_cluster = qemu_malloc(m->nb_clusters * sizeof(uint64_t));
+ old_cluster = g_malloc(m->nb_clusters * sizeof(uint64_t));
/* copy content of unmodified sectors */
start_sect = (m->offset & ~(s->cluster_size - 1)) >> 9;
@@ -683,7 +683,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
ret = 0;
err:
- qemu_free(old_cluster);
+ g_free(old_cluster);
return ret;
}
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 14b2f67f1..2a915be57 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -41,7 +41,7 @@ int qcow2_refcount_init(BlockDriverState *bs)
int ret, refcount_table_size2, i;
refcount_table_size2 = s->refcount_table_size * sizeof(uint64_t);
- s->refcount_table = qemu_malloc(refcount_table_size2);
+ s->refcount_table = g_malloc(refcount_table_size2);
if (s->refcount_table_size > 0) {
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD);
ret = bdrv_pread(bs->file, s->refcount_table_offset,
@@ -59,7 +59,7 @@ int qcow2_refcount_init(BlockDriverState *bs)
void qcow2_refcount_close(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
- qemu_free(s->refcount_table);
+ g_free(s->refcount_table);
}
@@ -323,8 +323,8 @@ static int alloc_refcount_block(BlockDriverState *bs,
uint64_t meta_offset = (blocks_used * refcount_block_clusters) *
s->cluster_size;
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
- uint16_t *new_blocks = qemu_mallocz(blocks_clusters * s->cluster_size);
- uint64_t *new_table = qemu_mallocz(table_size * sizeof(uint64_t));
+ uint16_t *new_blocks = g_malloc0(blocks_clusters * s->cluster_size);
+ uint64_t *new_table = g_malloc0(table_size * sizeof(uint64_t));
assert(meta_offset >= (s->free_cluster_index * s->cluster_size));
@@ -349,7 +349,7 @@ static int alloc_refcount_block(BlockDriverState *bs,
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks,
blocks_clusters * s->cluster_size);
- qemu_free(new_blocks);
+ g_free(new_blocks);
if (ret < 0) {
goto fail_table;
}
@@ -385,7 +385,7 @@ static int alloc_refcount_block(BlockDriverState *bs,
uint64_t old_table_offset = s->refcount_table_offset;
uint64_t old_table_size = s->refcount_table_size;
- qemu_free(s->refcount_table);
+ g_free(s->refcount_table);
s->refcount_table = new_table;
s->refcount_table_size = table_size;
s->refcount_table_offset = table_offset;
@@ -403,7 +403,7 @@ static int alloc_refcount_block(BlockDriverState *bs,
return new_block;
fail_table:
- qemu_free(new_table);
+ g_free(new_table);
fail_block:
if (*refcount_block != NULL) {
qcow2_cache_put(bs, s->refcount_block_cache, (void**) refcount_block);
@@ -720,7 +720,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
l1_size2 = l1_size * sizeof(uint64_t);
if (l1_table_offset != s->l1_table_offset) {
if (l1_size2 != 0) {
- l1_table = qemu_mallocz(align_offset(l1_size2, 512));
+ l1_table = g_malloc0(align_offset(l1_size2, 512));
} else {
l1_table = NULL;
}
@@ -847,7 +847,7 @@ fail:
be64_to_cpus(&l1_table[i]);
}
if (l1_allocated)
- qemu_free(l1_table);
+ g_free(l1_table);
return ret;
}
@@ -921,7 +921,7 @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
/* Read L2 table from disk */
l2_size = s->l2_size * sizeof(uint64_t);
- l2_table = qemu_malloc(l2_size);
+ l2_table = g_malloc(l2_size);
if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size)
goto fail;
@@ -979,12 +979,12 @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
}
}
- qemu_free(l2_table);
+ g_free(l2_table);
return 0;
fail:
fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n");
- qemu_free(l2_table);
+ g_free(l2_table);
return -EIO;
}
@@ -1017,7 +1017,7 @@ static int check_refcounts_l1(BlockDriverState *bs,
if (l1_size2 == 0) {
l1_table = NULL;
} else {
- l1_table = qemu_malloc(l1_size2);
+ l1_table = g_malloc(l1_size2);
if (bdrv_pread(bs->file, l1_table_offset,
l1_table, l1_size2) != l1_size2)
goto fail;
@@ -1065,13 +1065,13 @@ static int check_refcounts_l1(BlockDriverState *bs,
}
}
}
- qemu_free(l1_table);
+ g_free(l1_table);
return 0;
fail:
fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n");
res->check_errors++;
- qemu_free(l1_table);
+ g_free(l1_table);
return -EIO;
}
@@ -1092,7 +1092,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res)
size = bdrv_getlength(bs->file);
nb_clusters = size_to_clusters(s, size);
- refcount_table = qemu_mallocz(nb_clusters * sizeof(uint16_t));
+ refcount_table = g_malloc0(nb_clusters * sizeof(uint16_t));
/* header */
inc_refcounts(bs, res, refcount_table, nb_clusters,
@@ -1178,7 +1178,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res)
ret = 0;
fail:
- qemu_free(refcount_table);
+ g_free(refcount_table);
return ret;
}
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index e32bcf084..3bd2a30d3 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -52,10 +52,10 @@ void qcow2_free_snapshots(BlockDriverState *bs)
int i;
for(i = 0; i < s->nb_snapshots; i++) {
- qemu_free(s->snapshots[i].name);
- qemu_free(s->snapshots[i].id_str);
+ g_free(s->snapshots[i].name);
+ g_free(s->snapshots[i].id_str);
}
- qemu_free(s->snapshots);
+ g_free(s->snapshots);
s->snapshots = NULL;
s->nb_snapshots = 0;
}
@@ -76,7 +76,7 @@ int qcow2_read_snapshots(BlockDriverState *bs)
}
offset = s->snapshots_offset;
- s->snapshots = qemu_mallocz(s->nb_snapshots * sizeof(QCowSnapshot));
+ s->snapshots = g_malloc0(s->nb_snapshots * sizeof(QCowSnapshot));
for(i = 0; i < s->nb_snapshots; i++) {
offset = align_offset(offset, 8);
if (bdrv_pread(bs->file, offset, &h, sizeof(h)) != sizeof(h))
@@ -96,13 +96,13 @@ int qcow2_read_snapshots(BlockDriverState *bs)
offset += extra_data_size;
- sn->id_str = qemu_malloc(id_str_size + 1);
+ sn->id_str = g_malloc(id_str_size + 1);
if (bdrv_pread(bs->file, offset, sn->id_str, id_str_size) != id_str_size)
goto fail;
offset += id_str_size;
sn->id_str[id_str_size] = '\0';
- sn->name = qemu_malloc(name_size + 1);
+ sn->name = g_malloc(name_size + 1);
if (bdrv_pread(bs->file, offset, sn->name, name_size) != name_size)
goto fail;
offset += name_size;
@@ -252,10 +252,10 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
if (find_snapshot_by_id(bs, sn_info->id_str) >= 0)
return -ENOENT;
- sn->id_str = qemu_strdup(sn_info->id_str);
+ sn->id_str = g_strdup(sn_info->id_str);
if (!sn->id_str)
goto fail;
- sn->name = qemu_strdup(sn_info->name);
+ sn->name = g_strdup(sn_info->name);
if (!sn->name)
goto fail;
sn->vm_state_size = sn_info->vm_state_size;
@@ -278,7 +278,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
sn->l1_size = s->l1_size;
if (s->l1_size != 0) {
- l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
+ l1_table = g_malloc(s->l1_size * sizeof(uint64_t));
} else {
l1_table = NULL;
}
@@ -289,13 +289,13 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
if (bdrv_pwrite_sync(bs->file, sn->l1_table_offset,
l1_table, s->l1_size * sizeof(uint64_t)) < 0)
goto fail;
- qemu_free(l1_table);
+ g_free(l1_table);
l1_table = NULL;
- snapshots1 = qemu_malloc((s->nb_snapshots + 1) * sizeof(QCowSnapshot));
+ snapshots1 = g_malloc((s->nb_snapshots + 1) * sizeof(QCowSnapshot));
if (s->snapshots) {
memcpy(snapshots1, s->snapshots, s->nb_snapshots * sizeof(QCowSnapshot));
- qemu_free(s->snapshots);
+ g_free(s->snapshots);
}
s->snapshots = snapshots1;
s->snapshots[s->nb_snapshots++] = *sn;
@@ -307,8 +307,8 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
#endif
return 0;
fail:
- qemu_free(sn->name);
- qemu_free(l1_table);
+ g_free(sn->name);
+ g_free(l1_table);
return -1;
}
@@ -380,8 +380,8 @@ int qcow2_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
return ret;
qcow2_free_clusters(bs, sn->l1_table_offset, sn->l1_size * sizeof(uint64_t));
- qemu_free(sn->id_str);
- qemu_free(sn->name);
+ g_free(sn->id_str);
+ g_free(sn->name);
memmove(sn, sn + 1, (s->nb_snapshots - snapshot_index - 1) * sizeof(*sn));
s->nb_snapshots--;
ret = qcow2_write_snapshots(bs);
@@ -407,7 +407,7 @@ int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
return s->nb_snapshots;
}
- sn_tab = qemu_mallocz(s->nb_snapshots * sizeof(QEMUSnapshotInfo));
+ sn_tab = g_malloc0(s->nb_snapshots * sizeof(QEMUSnapshotInfo));
for(i = 0; i < s->nb_snapshots; i++) {
sn_info = sn_tab + i;
sn = s->snapshots + i;
@@ -439,11 +439,11 @@ int qcow2_snapshot_load_tmp(BlockDriverState *bs, const char *snapshot_name)
s->l1_size = sn->l1_size;
l1_size2 = s->l1_size * sizeof(uint64_t);
if (s->l1_table != NULL) {
- qemu_free(s->l1_table);
+ g_free(s->l1_table);
}
s->l1_table_offset = sn->l1_table_offset;
- s->l1_table = qemu_mallocz(align_offset(l1_size2, 512));
+ s->l1_table = g_malloc0(align_offset(l1_size2, 512));
if (bdrv_pread(bs->file, sn->l1_table_offset,
s->l1_table, l1_size2) != l1_size2) {
diff --git a/block/qcow2.c b/block/qcow2.c
index f07d550a9..bfff6cd96 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -216,7 +216,7 @@ static int qcow2_open(BlockDriverState *bs, int flags)
}
s->l1_table_offset = header.l1_table_offset;
if (s->l1_size > 0) {
- s->l1_table = qemu_mallocz(
+ s->l1_table = g_malloc0(
align_offset(s->l1_size * sizeof(uint64_t), 512));
ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
@@ -234,9 +234,9 @@ static int qcow2_open(BlockDriverState *bs, int flags)
s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE,
writethrough);
- s->cluster_cache = qemu_malloc(s->cluster_size);
+ s->cluster_cache = g_malloc(s->cluster_size);
/* one more sector for decompressed data alignment */
- s->cluster_data = qemu_malloc(QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size
+ s->cluster_data = g_malloc(QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size
+ 512);
s->cluster_cache_offset = -1;
@@ -287,12 +287,12 @@ static int qcow2_open(BlockDriverState *bs, int flags)
fail:
qcow2_free_snapshots(bs);
qcow2_refcount_close(bs);
- qemu_free(s->l1_table);
+ g_free(s->l1_table);
if (s->l2_table_cache) {
qcow2_cache_destroy(bs, s->l2_table_cache);
}
- qemu_free(s->cluster_cache);
- qemu_free(s->cluster_data);
+ g_free(s->cluster_cache);
+ g_free(s->cluster_data);
return ret;
}
@@ -501,7 +501,7 @@ static int qcow2_aio_read_cb(QCowAIOCB *acb)
*/
if (!acb->cluster_data) {
acb->cluster_data =
- qemu_mallocz(QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size);
+ g_malloc0(QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size);
}
assert(acb->cur_nr_sectors <=
@@ -636,7 +636,7 @@ static int qcow2_aio_write_cb(QCowAIOCB *acb)
if (s->crypt_method) {
if (!acb->cluster_data) {
- acb->cluster_data = qemu_mallocz(QCOW_MAX_CRYPT_CLUSTERS *
+ acb->cluster_data = g_malloc0(QCOW_MAX_CRYPT_CLUSTERS *
s->cluster_size);
}
@@ -691,7 +691,7 @@ static int qcow2_co_writev(BlockDriverState *bs,
static void qcow2_close(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
- qemu_free(s->l1_table);
+ g_free(s->l1_table);
qcow2_cache_flush(bs, s->l2_table_cache);
qcow2_cache_flush(bs, s->refcount_block_cache);
@@ -699,8 +699,8 @@ static void qcow2_close(BlockDriverState *bs)
qcow2_cache_destroy(bs, s->l2_table_cache);
qcow2_cache_destroy(bs, s->refcount_block_cache);
- qemu_free(s->cluster_cache);
- qemu_free(s->cluster_data);
+ g_free(s->cluster_cache);
+ g_free(s->cluster_data);
qcow2_refcount_close(bs);
}
@@ -923,9 +923,9 @@ static int qcow2_create2(const char *filename, int64_t total_size,
}
/* Write an empty refcount table */
- refcount_table = qemu_mallocz(cluster_size);
+ refcount_table = g_malloc0(cluster_size);
ret = bdrv_pwrite(bs, cluster_size, refcount_table, cluster_size);
- qemu_free(refcount_table);
+ g_free(refcount_table);
if (ret < 0) {
goto out;
@@ -1117,7 +1117,7 @@ static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num,
if (nb_sectors != s->cluster_sectors)
return -EINVAL;
- out_buf = qemu_malloc(s->cluster_size + (s->cluster_size / 1000) + 128);
+ out_buf = g_malloc(s->cluster_size + (s->cluster_size / 1000) + 128);
/* best compression, small window, no zlib header */
memset(&strm, 0, sizeof(strm));
@@ -1125,7 +1125,7 @@ static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num,
Z_DEFLATED, -12,
9, Z_DEFAULT_STRATEGY);
if (ret != 0) {
- qemu_free(out_buf);
+ g_free(out_buf);
return -1;
}
@@ -1136,7 +1136,7 @@ static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num,
ret = deflate(&strm, Z_FINISH);
if (ret != Z_STREAM_END && ret != Z_OK) {
- qemu_free(out_buf);
+ g_free(out_buf);
deflateEnd(&strm);
return -1;
}
@@ -1155,12 +1155,12 @@ static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num,
cluster_offset &= s->cluster_offset_mask;
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED);
if (bdrv_pwrite(bs->file, cluster_offset, out_buf, out_len) != out_len) {
- qemu_free(out_buf);
+ g_free(out_buf);
return -1;
}
}
- qemu_free(out_buf);
+ g_free(out_buf);
return 0;
}
diff --git a/block/qed-check.c b/block/qed-check.c
index 22cd07fa1..e4a49ce72 100644
--- a/block/qed-check.c
+++ b/block/qed-check.c
@@ -197,7 +197,7 @@ int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix)
};
int ret;
- check.used_clusters = qemu_mallocz(((check.nclusters + 31) / 32) *
+ check.used_clusters = g_malloc0(((check.nclusters + 31) / 32) *
sizeof(check.used_clusters[0]));
ret = qed_check_l1_table(&check, s->l1_table);
@@ -206,6 +206,6 @@ int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix)
qed_check_for_leaks(&check);
}
- qemu_free(check.used_clusters);
+ g_free(check.used_clusters);
return ret;
}
diff --git a/block/qed-cluster.c b/block/qed-cluster.c
index 3e19ad176..f64b2af8f 100644
--- a/block/qed-cluster.c
+++ b/block/qed-cluster.c
@@ -108,7 +108,7 @@ static void qed_find_cluster_cb(void *opaque, int ret)
out:
find_cluster_cb->cb(find_cluster_cb->opaque, ret, offset, len);
- qemu_free(find_cluster_cb);
+ g_free(find_cluster_cb);
}
/**
@@ -152,7 +152,7 @@ void qed_find_cluster(BDRVQEDState *s, QEDRequest *request, uint64_t pos,
return;
}
- find_cluster_cb = qemu_malloc(sizeof(*find_cluster_cb));
+ find_cluster_cb = g_malloc(sizeof(*find_cluster_cb));
find_cluster_cb->s = s;
find_cluster_cb->pos = pos;
find_cluster_cb->len = len;
diff --git a/block/qed-gencb.c b/block/qed-gencb.c
index 1513dc6f7..7d7ac1ffc 100644
--- a/block/qed-gencb.c
+++ b/block/qed-gencb.c
@@ -15,7 +15,7 @@
void *gencb_alloc(size_t len, BlockDriverCompletionFunc *cb, void *opaque)
{
- GenericCB *gencb = qemu_malloc(len);
+ GenericCB *gencb = g_malloc(len);
gencb->cb = cb;
gencb->opaque = opaque;
return gencb;
@@ -27,6 +27,6 @@ void gencb_complete(void *opaque, int ret)
BlockDriverCompletionFunc *cb = gencb->cb;
void *user_opaque = gencb->opaque;
- qemu_free(gencb);
+ g_free(gencb);
cb(user_opaque, ret);
}
diff --git a/block/qed-l2-cache.c b/block/qed-l2-cache.c
index 57518a4e7..02b81a2e3 100644
--- a/block/qed-l2-cache.c
+++ b/block/qed-l2-cache.c
@@ -74,7 +74,7 @@ void qed_free_l2_cache(L2TableCache *l2_cache)
QTAILQ_FOREACH_SAFE(entry, &l2_cache->entries, node, next_entry) {
qemu_vfree(entry->table);
- qemu_free(entry);
+ g_free(entry);
}
}
@@ -89,7 +89,7 @@ CachedL2Table *qed_alloc_l2_cache_entry(L2TableCache *l2_cache)
{
CachedL2Table *entry;
- entry = qemu_mallocz(sizeof(*entry));
+ entry = g_malloc0(sizeof(*entry));
entry->ref++;
trace_qed_alloc_l2_cache_entry(l2_cache, entry);
@@ -111,7 +111,7 @@ void qed_unref_l2_cache_entry(CachedL2Table *entry)
trace_qed_unref_l2_cache_entry(entry, entry->ref);
if (entry->ref == 0) {
qemu_vfree(entry->table);
- qemu_free(entry);
+ g_free(entry);
}
}
diff --git a/block/qed.c b/block/qed.c
index 333f06758..624e261b3 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -595,7 +595,7 @@ static int qed_create(const char *filename, uint32_t cluster_size,
goto out;
}
- l1_table = qemu_mallocz(l1_size);
+ l1_table = g_malloc0(l1_size);
ret = bdrv_pwrite(bs, header.l1_table_offset, l1_table, l1_size);
if (ret < 0) {
goto out;
@@ -603,7 +603,7 @@ static int qed_create(const char *filename, uint32_t cluster_size,
ret = 0; /* success */
out:
- qemu_free(l1_table);
+ g_free(l1_table);
bdrv_delete(bs);
return ret;
}
@@ -1419,7 +1419,7 @@ static int bdrv_qed_change_backing_file(BlockDriverState *bs,
}
/* Prepare new header */
- buffer = qemu_malloc(buffer_len);
+ buffer = g_malloc(buffer_len);
qed_header_cpu_to_le(&new_header, &le_header);
memcpy(buffer, &le_header, sizeof(le_header));
@@ -1430,7 +1430,7 @@ static int bdrv_qed_change_backing_file(BlockDriverState *bs,
/* Write new header */
ret = bdrv_pwrite_sync(bs->file, 0, buffer, buffer_len);
- qemu_free(buffer);
+ g_free(buffer);
if (ret == 0) {
memcpy(&s->header, &new_header, sizeof(new_header));
}
diff --git a/block/raw.c b/block/raw.c
index cb6203eec..555db4fa5 100644
--- a/block/raw.c
+++ b/block/raw.c
@@ -119,7 +119,7 @@ static int raw_has_zero_init(BlockDriverState *bs)
static BlockDriver bdrv_raw = {
.format_name = "raw",
- /* It's really 0, but we need to make qemu_malloc() happy */
+ /* It's really 0, but we need to make g_malloc() happy */
.instance_size = 1,
.bdrv_open = raw_open,
diff --git a/block/rbd.c b/block/rbd.c
index d5659cdf1..ce0f6ef6e 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -138,7 +138,7 @@ static int qemu_rbd_parsename(const char *filename,
return -EINVAL;
}
- buf = qemu_strdup(start);
+ buf = g_strdup(start);
p = buf;
*snap = '\0';
*conf = '\0';
@@ -165,7 +165,7 @@ static int qemu_rbd_parsename(const char *filename,
ret = qemu_rbd_next_tok(conf, conf_len, p, '\0', "configuration", &p);
done:
- qemu_free(buf);
+ g_free(buf);
return ret;
}
@@ -176,7 +176,7 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf)
char value[RBD_MAX_CONF_VAL_SIZE];
int ret = 0;
- buf = qemu_strdup(conf);
+ buf = g_strdup(conf);
p = buf;
while (p) {
@@ -214,7 +214,7 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf)
}
}
- qemu_free(buf);
+ g_free(buf);
return ret;
}
@@ -341,7 +341,7 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
acb->bh = qemu_bh_new(rbd_aio_bh_cb, acb);
qemu_bh_schedule(acb->bh);
done:
- qemu_free(rcb);
+ g_free(rcb);
}
/*
@@ -395,7 +395,7 @@ static int qemu_rbd_open(BlockDriverState *bs, const char *filename, int flags)
}
s->snap = NULL;
if (snap_buf[0] != '\0') {
- s->snap = qemu_strdup(snap_buf);
+ s->snap = g_strdup(snap_buf);
}
r = rados_create(&s->cluster, NULL);
@@ -478,7 +478,7 @@ static void qemu_rbd_close(BlockDriverState *bs)
rbd_close(s->image);
rados_ioctx_destroy(s->io_ctx);
- qemu_free(s->snap);
+ g_free(s->snap);
rados_shutdown(s->cluster);
}
@@ -544,7 +544,7 @@ static void rbd_finish_aiocb(rbd_completion_t c, RADOSCB *rcb)
ret = qemu_rbd_send_pipe(rcb->s, rcb);
if (ret < 0) {
error_report("failed writing to acb->s->fds");
- qemu_free(rcb);
+ g_free(rcb);
}
}
@@ -605,7 +605,7 @@ static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState *bs,
s->qemu_aio_count++; /* All the RADOSCB */
- rcb = qemu_malloc(sizeof(RADOSCB));
+ rcb = g_malloc(sizeof(RADOSCB));
rcb->done = 0;
rcb->acb = acb;
rcb->buf = buf;
@@ -629,7 +629,7 @@ static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState *bs,
return &acb->common;
failed:
- qemu_free(rcb);
+ g_free(rcb);
s->qemu_aio_count--;
qemu_aio_release(acb);
return NULL;
@@ -739,10 +739,10 @@ static int qemu_rbd_snap_list(BlockDriverState *bs,
int max_snaps = RBD_MAX_SNAPS;
do {
- snaps = qemu_malloc(sizeof(*snaps) * max_snaps);
+ snaps = g_malloc(sizeof(*snaps) * max_snaps);
snap_count = rbd_snap_list(s->image, snaps, &max_snaps);
if (snap_count < 0) {
- qemu_free(snaps);
+ g_free(snaps);
}
} while (snap_count == -ERANGE);
@@ -750,7 +750,7 @@ static int qemu_rbd_snap_list(BlockDriverState *bs,
return snap_count;
}
- sn_tab = qemu_mallocz(snap_count * sizeof(QEMUSnapshotInfo));
+ sn_tab = g_malloc0(snap_count * sizeof(QEMUSnapshotInfo));
for (i = 0; i < snap_count; i++) {
const char *snap_name = snaps[i].name;
diff --git a/block/sheepdog.c b/block/sheepdog.c
index e150ac012..57b6e1aad 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -368,7 +368,7 @@ static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb,
{
AIOReq *aio_req;
- aio_req = qemu_malloc(sizeof(*aio_req));
+ aio_req = g_malloc(sizeof(*aio_req));
aio_req->aiocb = acb;
aio_req->iov_offset = iov_offset;
aio_req->oid = oid;
@@ -390,7 +390,7 @@ static inline int free_aio_req(BDRVSheepdogState *s, AIOReq *aio_req)
SheepdogAIOCB *acb = aio_req->aiocb;
QLIST_REMOVE(aio_req, outstanding_aio_siblings);
QLIST_REMOVE(aio_req, aioreq_siblings);
- qemu_free(aio_req);
+ g_free(aio_req);
return !QLIST_EMPTY(&acb->aioreq_head);
}
@@ -470,7 +470,7 @@ static ssize_t sendmsg(int s, const struct msghdr *msg, int flags)
for (i = 0; i < msg->msg_iovlen; i++) {
size += msg->msg_iov[i].iov_len;
}
- buf = qemu_malloc(size);
+ buf = g_malloc(size);
p = buf;
for (i = 0; i < msg->msg_iovlen; i++) {
@@ -480,7 +480,7 @@ static ssize_t sendmsg(int s, const struct msghdr *msg, int flags)
ret = send(s, buf, size, flags);
- qemu_free(buf);
+ g_free(buf);
return ret;
}
@@ -494,7 +494,7 @@ static ssize_t recvmsg(int s, struct msghdr *msg, int flags)
for (i = 0; i < msg->msg_iovlen; i++) {
size += msg->msg_iov[i].iov_len;
}
- buf = qemu_malloc(size);
+ buf = g_malloc(size);
ret = qemu_recv(s, buf, size, flags);
if (ret < 0) {
@@ -507,7 +507,7 @@ static ssize_t recvmsg(int s, struct msghdr *msg, int flags)
p += msg->msg_iov[i].iov_len;
}
out:
- qemu_free(buf);
+ g_free(buf);
return ret;
}
@@ -952,7 +952,7 @@ static int parse_vdiname(BDRVSheepdogState *s, const char *filename,
char *p, *q;
int nr_sep;
- p = q = qemu_strdup(filename);
+ p = q = g_strdup(filename);
/* count the number of separators */
nr_sep = 0;
@@ -992,7 +992,7 @@ static int parse_vdiname(BDRVSheepdogState *s, const char *filename,
}
if (s->addr == NULL) {
- qemu_free(q);
+ g_free(q);
}
return 0;
@@ -1210,7 +1210,7 @@ static int sd_open(BlockDriverState *bs, const char *filename, int flags)
goto out;
}
- buf = qemu_malloc(SD_INODE_SIZE);
+ buf = g_malloc(SD_INODE_SIZE);
ret = read_object(fd, buf, vid_to_vdi_oid(vid), 0, SD_INODE_SIZE, 0);
closesocket(fd);
@@ -1225,14 +1225,14 @@ static int sd_open(BlockDriverState *bs, const char *filename, int flags)
bs->total_sectors = s->inode.vdi_size / SECTOR_SIZE;
strncpy(s->name, vdi, sizeof(s->name));
- qemu_free(buf);
+ g_free(buf);
return 0;
out:
qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL, NULL);
if (s->fd >= 0) {
closesocket(s->fd);
}
- qemu_free(buf);
+ g_free(buf);
return -1;
}
@@ -1291,7 +1291,7 @@ static int sd_prealloc(const char *filename)
BlockDriverState *bs = NULL;
uint32_t idx, max_idx;
int64_t vdi_size;
- void *buf = qemu_mallocz(SD_DATA_OBJ_SIZE);
+ void *buf = g_malloc0(SD_DATA_OBJ_SIZE);
int ret;
ret = bdrv_file_open(&bs, filename, BDRV_O_RDWR);
@@ -1324,7 +1324,7 @@ out:
if (bs) {
bdrv_delete(bs);
}
- qemu_free(buf);
+ g_free(buf);
return ret;
}
@@ -1444,7 +1444,7 @@ static void sd_close(BlockDriverState *bs)
qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL, NULL);
closesocket(s->fd);
- qemu_free(s->addr);
+ g_free(s->addr);
}
static int64_t sd_getlength(BlockDriverState *bs)
@@ -1542,7 +1542,7 @@ static int sd_create_branch(BDRVSheepdogState *s)
dprintf("%" PRIx32 " is snapshot.\n", s->inode.vdi_id);
- buf = qemu_malloc(SD_INODE_SIZE);
+ buf = g_malloc(SD_INODE_SIZE);
ret = do_sd_create(s->name, s->inode.vdi_size, s->inode.vdi_id, &vid, 1,
s->addr, s->port);
@@ -1574,7 +1574,7 @@ static int sd_create_branch(BDRVSheepdogState *s)
dprintf("%" PRIx32 " was newly created.\n", s->inode.vdi_id);
out:
- qemu_free(buf);
+ g_free(buf);
return ret;
}
@@ -1786,7 +1786,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
goto cleanup;
}
- inode = (SheepdogInode *)qemu_malloc(datalen);
+ inode = (SheepdogInode *)g_malloc(datalen);
ret = read_object(fd, (char *)inode, vid_to_vdi_oid(new_vid),
s->inode.nr_copies, datalen, 0);
@@ -1816,7 +1816,7 @@ static int sd_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
uint32_t snapid = 0;
int ret = -ENOENT, fd;
- old_s = qemu_malloc(sizeof(BDRVSheepdogState));
+ old_s = g_malloc(sizeof(BDRVSheepdogState));
memcpy(old_s, s, sizeof(BDRVSheepdogState));
@@ -1842,7 +1842,7 @@ static int sd_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
goto out;
}
- buf = qemu_malloc(SD_INODE_SIZE);
+ buf = g_malloc(SD_INODE_SIZE);
ret = read_object(fd, buf, vid_to_vdi_oid(vid), s->inode.nr_copies,
SD_INODE_SIZE, 0);
@@ -1863,15 +1863,15 @@ static int sd_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
s->is_snapshot = 1;
- qemu_free(buf);
- qemu_free(old_s);
+ g_free(buf);
+ g_free(old_s);
return 0;
out:
/* recover bdrv_sd_state */
memcpy(s, old_s, sizeof(BDRVSheepdogState));
- qemu_free(buf);
- qemu_free(old_s);
+ g_free(buf);
+ g_free(old_s);
error_report("failed to open. recover old bdrv_sd_state.");
@@ -1898,7 +1898,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
uint64_t hval;
uint32_t vid;
- vdi_inuse = qemu_malloc(max);
+ vdi_inuse = g_malloc(max);
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
@@ -1920,7 +1920,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
goto out;
}
- sn_tab = qemu_mallocz(nr * sizeof(*sn_tab));
+ sn_tab = g_malloc0(nr * sizeof(*sn_tab));
/* calculate a vdi id with hash function */
hval = fnv_64a_buf(s->name, strlen(s->name), FNV1A_64_INIT);
@@ -1963,7 +1963,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
out:
*psn_tab = sn_tab;
- qemu_free(vdi_inuse);
+ g_free(vdi_inuse);
return found;
}
diff --git a/block/vdi.c b/block/vdi.c
index 261cf9b98..1d5ad2bf4 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -301,7 +301,7 @@ static int vdi_check(BlockDriverState *bs, BdrvCheckResult *res)
uint32_t *bmap;
logout("\n");
- bmap = qemu_malloc(s->header.blocks_in_image * sizeof(uint32_t));
+ bmap = g_malloc(s->header.blocks_in_image * sizeof(uint32_t));
memset(bmap, 0xff, s->header.blocks_in_image * sizeof(uint32_t));
/* Check block map and value of blocks_allocated. */
@@ -331,7 +331,7 @@ static int vdi_check(BlockDriverState *bs, BdrvCheckResult *res)
res->corruptions++;
}
- qemu_free(bmap);
+ g_free(bmap);
return 0;
}
@@ -443,7 +443,7 @@ static int vdi_open(BlockDriverState *bs, int flags)
bmap_size = header.blocks_in_image * sizeof(uint32_t);
bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;
if (bmap_size > 0) {
- s->bmap = qemu_malloc(bmap_size * SECTOR_SIZE);
+ s->bmap = g_malloc(bmap_size * SECTOR_SIZE);
}
if (bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size) < 0) {
goto fail_free_bmap;
@@ -452,7 +452,7 @@ static int vdi_open(BlockDriverState *bs, int flags)
return 0;
fail_free_bmap:
- qemu_free(s->bmap);
+ g_free(s->bmap);
fail:
return -1;
@@ -704,7 +704,7 @@ static void vdi_aio_write_cb(void *opaque, int ret)
uint64_t offset;
uint32_t bmap_first;
uint32_t bmap_last;
- qemu_free(acb->block_buffer);
+ g_free(acb->block_buffer);
acb->block_buffer = NULL;
bmap_first = acb->bmap_first;
bmap_last = acb->bmap_last;
@@ -760,7 +760,7 @@ static void vdi_aio_write_cb(void *opaque, int ret)
(uint64_t)bmap_entry * s->block_sectors;
block = acb->block_buffer;
if (block == NULL) {
- block = qemu_mallocz(s->block_size);
+ block = g_malloc0(s->block_size);
acb->block_buffer = block;
acb->bmap_first = block_index;
assert(!acb->header_modified);
@@ -906,7 +906,7 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options)
bmap = NULL;
if (bmap_size > 0) {
- bmap = (uint32_t *)qemu_mallocz(bmap_size);
+ bmap = (uint32_t *)g_malloc0(bmap_size);
}
for (i = 0; i < blocks; i++) {
if (image_type == VDI_TYPE_STATIC) {
@@ -918,7 +918,7 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options)
if (write(fd, bmap, bmap_size) < 0) {
result = -errno;
}
- qemu_free(bmap);
+ g_free(bmap);
if (image_type == VDI_TYPE_STATIC) {
if (ftruncate(fd, sizeof(header) + bmap_size + blocks * block_size)) {
result = -errno;
diff --git a/block/vmdk.c b/block/vmdk.c
index 37478d255..8da87acef 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -167,11 +167,11 @@ static void vmdk_free_extents(BlockDriverState *bs)
BDRVVmdkState *s = bs->opaque;
for (i = 0; i < s->num_extents; i++) {
- qemu_free(s->extents[i].l1_table);
- qemu_free(s->extents[i].l2_cache);
- qemu_free(s->extents[i].l1_backup_table);
+ g_free(s->extents[i].l1_table);
+ g_free(s->extents[i].l2_cache);
+ g_free(s->extents[i].l1_backup_table);
}
- qemu_free(s->extents);
+ g_free(s->extents);
}
static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
@@ -289,7 +289,7 @@ static VmdkExtent *vmdk_add_extent(BlockDriverState *bs,
VmdkExtent *extent;
BDRVVmdkState *s = bs->opaque;
- s->extents = qemu_realloc(s->extents,
+ s->extents = g_realloc(s->extents,
(s->num_extents + 1) * sizeof(VmdkExtent));
extent = &s->extents[s->num_extents];
s->num_extents++;
@@ -321,7 +321,7 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent)
/* read the L1 table */
l1_size = extent->l1_size * sizeof(uint32_t);
- extent->l1_table = qemu_malloc(l1_size);
+ extent->l1_table = g_malloc(l1_size);
ret = bdrv_pread(extent->file,
extent->l1_table_offset,
extent->l1_table,
@@ -334,7 +334,7 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent)
}
if (extent->l1_backup_table_offset) {
- extent->l1_backup_table = qemu_malloc(l1_size);
+ extent->l1_backup_table = g_malloc(l1_size);
ret = bdrv_pread(extent->file,
extent->l1_backup_table_offset,
extent->l1_backup_table,
@@ -348,12 +348,12 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent)
}
extent->l2_cache =
- qemu_malloc(extent->l2_size * L2_CACHE_SIZE * sizeof(uint32_t));
+ g_malloc(extent->l2_size * L2_CACHE_SIZE * sizeof(uint32_t));
return 0;
fail_l1b:
- qemu_free(extent->l1_backup_table);
+ g_free(extent->l1_backup_table);
fail_l1:
- qemu_free(extent->l1_table);
+ g_free(extent->l1_table);
return ret;
}
@@ -564,7 +564,7 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags)
/* try to open parent images, if exist */
if (vmdk_parent_open(bs)) {
- qemu_free(s->extents);
+ g_free(s->extents);
return -EINVAL;
}
s->parent_cid = vmdk_read_cid(bs, 1);
diff --git a/block/vpc.c b/block/vpc.c
index fdd523689..cb6c570f4 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -196,7 +196,7 @@ static int vpc_open(BlockDriverState *bs, int flags)
s->bitmap_size = ((s->block_size / (8 * 512)) + 511) & ~511;
s->max_table_entries = be32_to_cpu(dyndisk_header->max_table_entries);
- s->pagetable = qemu_malloc(s->max_table_entries * 4);
+ s->pagetable = g_malloc(s->max_table_entries * 4);
s->bat_offset = be64_to_cpu(dyndisk_header->table_offset);
if (bdrv_pread(bs->file, s->bat_offset, s->pagetable,
@@ -220,7 +220,7 @@ static int vpc_open(BlockDriverState *bs, int flags)
s->last_bitmap_offset = (int64_t) -1;
#ifdef CACHE
- s->pageentry_u8 = qemu_malloc(512);
+ s->pageentry_u8 = g_malloc(512);
s->pageentry_u32 = s->pageentry_u8;
s->pageentry_u16 = s->pageentry_u8;
s->last_pagetable = -1;
@@ -619,9 +619,9 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options)
static void vpc_close(BlockDriverState *bs)
{
BDRVVPCState *s = bs->opaque;
- qemu_free(s->pagetable);
+ g_free(s->pagetable);
#ifdef CACHE
- qemu_free(s->pageentry_u8);
+ g_free(s->pageentry_u8);
#endif
}
diff --git a/block/vvfat.c b/block/vvfat.c
index fe568fe2c..d6a07efcc 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -101,7 +101,7 @@ static inline int array_ensure_allocated(array_t* array, int index)
{
if((index + 1) * array->item_size > array->size) {
int new_size = (index + 32) * array->item_size;
- array->pointer = qemu_realloc(array->pointer, new_size);
+ array->pointer = g_realloc(array->pointer, new_size);
if (!array->pointer)
return -1;
array->size = new_size;
@@ -127,7 +127,7 @@ static inline void* array_get_next(array_t* array) {
static inline void* array_insert(array_t* array,unsigned int index,unsigned int count) {
if((array->next+count)*array->item_size>array->size) {
int increment=count*array->item_size;
- array->pointer=qemu_realloc(array->pointer,array->size+increment);
+ array->pointer=g_realloc(array->pointer,array->size+increment);
if(!array->pointer)
return NULL;
array->size+=increment;
@@ -159,7 +159,7 @@ static inline int array_roll(array_t* array,int index_to,int index_from,int coun
is=array->item_size;
from=array->pointer+index_from*is;
to=array->pointer+index_to*is;
- buf=qemu_malloc(is*count);
+ buf=g_malloc(is*count);
memcpy(buf,from,is*count);
if(index_to<index_from)
@@ -728,7 +728,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
if(first_cluster == 0 && (is_dotdot || is_dot))
continue;
- buffer=(char*)qemu_malloc(length);
+ buffer=(char*)g_malloc(length);
snprintf(buffer,length,"%s/%s",dirname,entry->d_name);
if(stat(buffer,&st)<0) {
@@ -850,7 +850,7 @@ static int init_directories(BDRVVVFATState* s,
memset(&(s->first_sectors[0]),0,0x40*0x200);
s->cluster_size=s->sectors_per_cluster*0x200;
- s->cluster_buffer=qemu_malloc(s->cluster_size);
+ s->cluster_buffer=g_malloc(s->cluster_size);
/*
* The formula: sc = spf+1+spf*spc*(512*8/fat_type),
@@ -884,7 +884,7 @@ static int init_directories(BDRVVVFATState* s,
mapping->dir_index = 0;
mapping->info.dir.parent_mapping_index = -1;
mapping->first_mapping_index = -1;
- mapping->path = qemu_strdup(dirname);
+ mapping->path = g_strdup(dirname);
i = strlen(mapping->path);
if (i > 0 && mapping->path[i - 1] == '/')
mapping->path[i - 1] = '\0';
@@ -1638,10 +1638,10 @@ static uint32_t get_cluster_count_for_direntry(BDRVVVFATState* s,
/* rename */
if (strcmp(basename, basename2))
- schedule_rename(s, cluster_num, qemu_strdup(path));
+ schedule_rename(s, cluster_num, g_strdup(path));
} else if (is_file(direntry))
/* new file */
- schedule_new_file(s, qemu_strdup(path), cluster_num);
+ schedule_new_file(s, g_strdup(path), cluster_num);
else {
abort();
return 0;
@@ -1735,7 +1735,7 @@ static int check_directory_consistency(BDRVVVFATState *s,
int cluster_num, const char* path)
{
int ret = 0;
- unsigned char* cluster = qemu_malloc(s->cluster_size);
+ unsigned char* cluster = g_malloc(s->cluster_size);
direntry_t* direntries = (direntry_t*)cluster;
mapping_t* mapping = find_mapping_for_cluster(s, cluster_num);
@@ -1758,10 +1758,10 @@ static int check_directory_consistency(BDRVVVFATState *s,
mapping->mode &= ~MODE_DELETED;
if (strcmp(basename, basename2))
- schedule_rename(s, cluster_num, qemu_strdup(path));
+ schedule_rename(s, cluster_num, g_strdup(path));
} else
/* new directory */
- schedule_mkdir(s, cluster_num, qemu_strdup(path));
+ schedule_mkdir(s, cluster_num, g_strdup(path));
lfn_init(&lfn);
do {
@@ -1876,7 +1876,7 @@ DLOG(checkpoint());
*/
if (s->fat2 == NULL) {
int size = 0x200 * s->sectors_per_fat;
- s->fat2 = qemu_malloc(size);
+ s->fat2 = g_malloc(size);
memcpy(s->fat2, s->fat.pointer, size);
}
check = vvfat_read(s->bs,
@@ -2218,7 +2218,7 @@ static int commit_one_file(BDRVVVFATState* s,
uint32_t first_cluster = c;
mapping_t* mapping = find_mapping_for_cluster(s, c);
uint32_t size = filesize_of_direntry(direntry);
- char* cluster = qemu_malloc(s->cluster_size);
+ char* cluster = g_malloc(s->cluster_size);
uint32_t i;
int fd = 0;
@@ -2383,7 +2383,7 @@ static int handle_renames_and_mkdirs(BDRVVVFATState* s)
mapping_t* m = find_mapping_for_cluster(s,
begin_of_direntry(d));
int l = strlen(m->path);
- char* new_path = qemu_malloc(l + diff + 1);
+ char* new_path = g_malloc(l + diff + 1);
assert(!strncmp(m->path, mapping->path, l2));
@@ -2794,7 +2794,7 @@ static int enable_write_target(BDRVVVFATState *s)
array_init(&(s->commits), sizeof(commit_t));
- s->qcow_filename = qemu_malloc(1024);
+ s->qcow_filename = g_malloc(1024);
get_tmp_filename(s->qcow_filename, 1024);
bdrv_qcow = bdrv_find_format("qcow");
@@ -2822,7 +2822,7 @@ static int enable_write_target(BDRVVVFATState *s)
s->bs->backing_hd = calloc(sizeof(BlockDriverState), 1);
s->bs->backing_hd->drv = &vvfat_write_target;
- s->bs->backing_hd->opaque = qemu_malloc(sizeof(void*));
+ s->bs->backing_hd->opaque = g_malloc(sizeof(void*));
*(void**)s->bs->backing_hd->opaque = s;
return 0;
diff --git a/blockdev.c b/blockdev.c
index a25367a9e..d272659ab 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -182,9 +182,9 @@ static void drive_uninit(DriveInfo *dinfo)
{
qemu_opts_del(dinfo->opts);
bdrv_delete(dinfo->bdrv);
- qemu_free(dinfo->id);
+ g_free(dinfo->id);
QTAILQ_REMOVE(&drives, dinfo, next);
- qemu_free(dinfo);
+ g_free(dinfo);
}
void drive_put_ref(DriveInfo *dinfo)
@@ -442,12 +442,12 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
/* init */
- dinfo = qemu_mallocz(sizeof(*dinfo));
+ dinfo = g_malloc0(sizeof(*dinfo));
if ((buf = qemu_opts_id(opts)) != NULL) {
- dinfo->id = qemu_strdup(buf);
+ dinfo->id = g_strdup(buf);
} else {
/* no id supplied -> create one */
- dinfo->id = qemu_mallocz(32);
+ dinfo->id = g_malloc0(32);
if (type == IF_IDE || type == IF_SCSI)
mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
if (max_devs)
@@ -542,9 +542,9 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
err:
bdrv_delete(dinfo->bdrv);
- qemu_free(dinfo->id);
+ g_free(dinfo->id);
QTAILQ_REMOVE(&drives, dinfo, next);
- qemu_free(dinfo);
+ g_free(dinfo);
return NULL;
}
diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c
index 207c774fb..5d6cffc45 100644
--- a/bsd-user/mmap.c
+++ b/bsd-user/mmap.c
@@ -94,7 +94,7 @@ void *qemu_vmalloc(size_t size)
return p;
}
-void *qemu_malloc(size_t size)
+void *g_malloc(size_t size)
{
char * p;
size += 16;
@@ -104,12 +104,12 @@ void *qemu_malloc(size_t size)
}
/* We use map, which is always zero initialized. */
-void * qemu_mallocz(size_t size)
+void * g_malloc0(size_t size)
{
- return qemu_malloc(size);
+ return g_malloc(size);
}
-void qemu_free(void *ptr)
+void g_free(void *ptr)
{
/* FIXME: We should unmark the reserved pages here. However this gets
complicated when one target page spans multiple host pages, so we
@@ -119,18 +119,18 @@ void qemu_free(void *ptr)
munmap(p, *p);
}
-void *qemu_realloc(void *ptr, size_t size)
+void *g_realloc(void *ptr, size_t size)
{
size_t old_size, copy;
void *new_ptr;
if (!ptr)
- return qemu_malloc(size);
+ return g_malloc(size);
old_size = *(size_t *)((char *)ptr - 16);
copy = old_size < size ? old_size : size;
- new_ptr = qemu_malloc(size);
+ new_ptr = g_malloc(size);
memcpy(new_ptr, ptr, copy);
- qemu_free(ptr);
+ g_free(ptr);
return new_ptr;
}
diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index d4d039a2f..18b43f1a2 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -231,7 +231,7 @@ static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ulong ol
void *hnamep, *holdp, *hnewp = NULL;
size_t holdlen;
abi_ulong oldlen = 0;
- int32_t *snamep = qemu_malloc(sizeof(int32_t) * namelen), *p, *q, i;
+ int32_t *snamep = g_malloc(sizeof(int32_t) * namelen), *p, *q, i;
uint32_t kind = 0;
if (oldlenp)
@@ -255,7 +255,7 @@ static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ulong ol
unlock_user(holdp, oldp, holdlen);
if (hnewp)
unlock_user(hnewp, newp, 0);
- qemu_free(snamep);
+ g_free(snamep);
return ret;
}
#endif
diff --git a/bt-host.c b/bt-host.c
index 095254ddc..df5b7cdac 100644
--- a/bt-host.c
+++ b/bt-host.c
@@ -177,7 +177,7 @@ struct HCIInfo *bt_host_hci(const char *id)
}
# endif
- s = qemu_mallocz(sizeof(struct bt_host_hci_s));
+ s = g_malloc0(sizeof(struct bt_host_hci_s));
s->fd = fd;
s->hci.cmd_send = bt_host_cmd;
s->hci.sco_send = bt_host_sco;
diff --git a/bt-vhci.c b/bt-vhci.c
index 3c5772093..bbc102985 100644
--- a/bt-vhci.c
+++ b/bt-vhci.c
@@ -156,7 +156,7 @@ void bt_vhci_init(struct HCIInfo *info)
exit(-1);
}
- s = qemu_mallocz(sizeof(struct bt_vhci_s));
+ s = g_malloc0(sizeof(struct bt_vhci_s));
s->fd = fd;
s->info = info ?: qemu_next_hci();
s->info->opaque = s;
diff --git a/buffered_file.c b/buffered_file.c
index 41b42c3d5..486af575d 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -56,7 +56,7 @@ static void buffered_append(QEMUFileBuffered *s,
s->buffer_capacity += size + 1024;
- tmp = qemu_realloc(s->buffer, s->buffer_capacity);
+ tmp = g_realloc(s->buffer, s->buffer_capacity);
if (tmp == NULL) {
fprintf(stderr, "qemu file buffer expansion failed\n");
exit(1);
@@ -183,8 +183,8 @@ static int buffered_close(void *opaque)
qemu_del_timer(s->timer);
qemu_free_timer(s->timer);
- qemu_free(s->buffer);
- qemu_free(s);
+ g_free(s->buffer);
+ g_free(s);
return ret;
}
@@ -259,7 +259,7 @@ QEMUFile *qemu_fopen_ops_buffered(void *opaque,
{
QEMUFileBuffered *s;
- s = qemu_mallocz(sizeof(*s));
+ s = g_malloc0(sizeof(*s));
s->opaque = opaque;
s->xfer_limit = bytes_per_sec / 10;
diff --git a/check-qdict.c b/check-qdict.c
index ecc7fd7b9..5515773b8 100644
--- a/check-qdict.c
+++ b/check-qdict.c
@@ -56,9 +56,9 @@ START_TEST(qdict_put_obj_test)
// destroy doesn't exit yet
QDECREF(qi);
- qemu_free(ent->key);
- qemu_free(ent);
- qemu_free(qdict);
+ g_free(ent->key);
+ g_free(ent);
+ g_free(qdict);
}
END_TEST
diff --git a/check-qfloat.c b/check-qfloat.c
index b71d9834f..3344057b3 100644
--- a/check-qfloat.c
+++ b/check-qfloat.c
@@ -33,7 +33,7 @@ START_TEST(qfloat_from_double_test)
fail_unless(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);
// destroy doesn't exit yet
- qemu_free(qf);
+ g_free(qf);
}
END_TEST
diff --git a/check-qint.c b/check-qint.c
index f3b031698..3af51f20c 100644
--- a/check-qint.c
+++ b/check-qint.c
@@ -32,7 +32,7 @@ START_TEST(qint_from_int_test)
fail_unless(qobject_type(QOBJECT(qi)) == QTYPE_QINT);
// destroy doesn't exit yet
- qemu_free(qi);
+ g_free(qi);
}
END_TEST
diff --git a/check-qlist.c b/check-qlist.c
index 58984cbfc..ee2454a27 100644
--- a/check-qlist.c
+++ b/check-qlist.c
@@ -30,7 +30,7 @@ START_TEST(qlist_new_test)
fail_unless(qobject_type(QOBJECT(qlist)) == QTYPE_QLIST);
// destroy doesn't exist yet
- qemu_free(qlist);
+ g_free(qlist);
}
END_TEST
@@ -51,8 +51,8 @@ START_TEST(qlist_append_test)
// destroy doesn't exist yet
QDECREF(qi);
- qemu_free(entry);
- qemu_free(qlist);
+ g_free(entry);
+ g_free(qlist);
}
END_TEST
@@ -65,7 +65,7 @@ START_TEST(qobject_to_qlist_test)
fail_unless(qobject_to_qlist(QOBJECT(qlist)) == qlist);
// destroy doesn't exist yet
- qemu_free(qlist);
+ g_free(qlist);
}
END_TEST
diff --git a/check-qstring.c b/check-qstring.c
index c9bafc26b..93bd4757b 100644
--- a/check-qstring.c
+++ b/check-qstring.c
@@ -32,8 +32,8 @@ START_TEST(qstring_from_str_test)
fail_unless(qobject_type(QOBJECT(qstring)) == QTYPE_QSTRING);
// destroy doesn't exit yet
- qemu_free(qstring->string);
- qemu_free(qstring);
+ g_free(qstring->string);
+ g_free(qstring);
}
END_TEST
diff --git a/console.c b/console.c
index 242086cf4..ec529ae6e 100644
--- a/console.c
+++ b/console.c
@@ -516,7 +516,7 @@ static void text_console_resize(TextConsole *s)
if (s->width < w1)
w1 = s->width;
- cells = qemu_malloc(s->width * s->total_height * sizeof(TextCell));
+ cells = g_malloc(s->width * s->total_height * sizeof(TextCell));
for(y = 0; y < s->total_height; y++) {
c = &cells[y * s->width];
if (w1 > 0) {
@@ -531,7 +531,7 @@ static void text_console_resize(TextConsole *s)
c++;
}
}
- qemu_free(s->cells);
+ g_free(s->cells);
s->cells = cells;
}
@@ -1252,7 +1252,7 @@ static TextConsole *new_console(DisplayState *ds, console_type_t console_type)
if (nb_consoles >= MAX_CONSOLES)
return NULL;
- s = qemu_mallocz(sizeof(TextConsole));
+ s = g_malloc0(sizeof(TextConsole));
if (!active_console || ((active_console->console_type != GRAPHIC_CONSOLE) &&
(console_type == GRAPHIC_CONSOLE))) {
active_console = s;
@@ -1276,7 +1276,7 @@ static TextConsole *new_console(DisplayState *ds, console_type_t console_type)
static DisplaySurface* defaultallocator_create_displaysurface(int width, int height)
{
- DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
+ DisplaySurface *surface = (DisplaySurface*) g_malloc0(sizeof(DisplaySurface));
int linesize = width * 4;
qemu_alloc_display(surface, width, height, linesize,
@@ -1302,10 +1302,10 @@ void qemu_alloc_display(DisplaySurface *surface, int width, int height,
surface->linesize = linesize;
surface->pf = pf;
if (surface->flags & QEMU_ALLOCATED_FLAG) {
- data = qemu_realloc(surface->data,
+ data = g_realloc(surface->data,
surface->linesize * surface->height);
} else {
- data = qemu_malloc(surface->linesize * surface->height);
+ data = g_malloc(surface->linesize * surface->height);
}
surface->data = (uint8_t *)data;
surface->flags = newflags | QEMU_ALLOCATED_FLAG;
@@ -1317,7 +1317,7 @@ void qemu_alloc_display(DisplaySurface *surface, int width, int height,
DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
int linesize, uint8_t *data)
{
- DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
+ DisplaySurface *surface = (DisplaySurface*) g_malloc0(sizeof(DisplaySurface));
surface->width = width;
surface->height = height;
@@ -1336,8 +1336,8 @@ static void defaultallocator_free_displaysurface(DisplaySurface *surface)
if (surface == NULL)
return;
if (surface->flags & QEMU_ALLOCATED_FLAG)
- qemu_free(surface->data);
- qemu_free(surface);
+ g_free(surface->data);
+ g_free(surface);
}
static struct DisplayAllocator default_allocator = {
@@ -1348,7 +1348,7 @@ static struct DisplayAllocator default_allocator = {
static void dumb_display_init(void)
{
- DisplayState *ds = qemu_mallocz(sizeof(DisplayState));
+ DisplayState *ds = g_malloc0(sizeof(DisplayState));
int width = 640;
int height = 480;
@@ -1403,14 +1403,14 @@ DisplayState *graphic_console_init(vga_hw_update_ptr update,
TextConsole *s;
DisplayState *ds;
- ds = (DisplayState *) qemu_mallocz(sizeof(DisplayState));
+ ds = (DisplayState *) g_malloc0(sizeof(DisplayState));
ds->allocator = &default_allocator;
ds->surface = qemu_create_displaysurface(ds, 640, 480);
s = new_console(ds, GRAPHIC_CONSOLE);
if (s == NULL) {
qemu_free_displaysurface(ds);
- qemu_free(ds);
+ g_free(ds);
return NULL;
}
s->hw_update = update;
@@ -1521,7 +1521,7 @@ int text_console_init(QemuOpts *opts, CharDriverState **_chr)
unsigned width;
unsigned height;
- chr = qemu_mallocz(sizeof(CharDriverState));
+ chr = g_malloc0(sizeof(CharDriverState));
if (n_text_consoles == 128) {
fprintf(stderr, "Too many text consoles\n");
diff --git a/coroutine-gthread.c b/coroutine-gthread.c
index f09877e14..b00e548b2 100644
--- a/coroutine-gthread.c
+++ b/coroutine-gthread.c
@@ -71,11 +71,11 @@ Coroutine *qemu_coroutine_new(void)
{
CoroutineGThread *co;
- co = qemu_mallocz(sizeof(*co));
+ co = g_malloc0(sizeof(*co));
co->thread = g_thread_create_full(coroutine_thread, co, 0, TRUE, TRUE,
G_THREAD_PRIORITY_NORMAL, NULL);
if (!co->thread) {
- qemu_free(co);
+ g_free(co);
return NULL;
}
return &co->base;
@@ -86,7 +86,7 @@ void qemu_coroutine_delete(Coroutine *co_)
CoroutineGThread *co = DO_UPCAST(CoroutineGThread, base, co_);
g_thread_join(co->thread);
- qemu_free(co);
+ g_free(co);
}
CoroutineAction qemu_coroutine_switch(Coroutine *from_,
@@ -115,7 +115,7 @@ Coroutine *qemu_coroutine_self(void)
CoroutineGThread *co = g_static_private_get(&coroutine_key);
if (!co) {
- co = qemu_mallocz(sizeof(*co));
+ co = g_malloc0(sizeof(*co));
co->runnable = true;
g_static_private_set(&coroutine_key, co, (GDestroyNotify)qemu_free);
}
diff --git a/coroutine-ucontext.c b/coroutine-ucontext.c
index 42dc3e2cf..2b8d3e9c1 100644
--- a/coroutine-ucontext.c
+++ b/coroutine-ucontext.c
@@ -73,7 +73,7 @@ static CoroutineThreadState *coroutine_get_thread_state(void)
CoroutineThreadState *s = pthread_getspecific(thread_state_key);
if (!s) {
- s = qemu_mallocz(sizeof(*s));
+ s = g_malloc0(sizeof(*s));
s->current = &s->leader.base;
QLIST_INIT(&s->pool);
pthread_setspecific(thread_state_key, s);
@@ -88,10 +88,10 @@ static void qemu_coroutine_thread_cleanup(void *opaque)
Coroutine *tmp;
QLIST_FOREACH_SAFE(co, &s->pool, pool_next, tmp) {
- qemu_free(DO_UPCAST(CoroutineUContext, base, co)->stack);
- qemu_free(co);
+ g_free(DO_UPCAST(CoroutineUContext, base, co)->stack);
+ g_free(co);
}
- qemu_free(s);
+ g_free(s);
}
static void __attribute__((constructor)) coroutine_init(void)
@@ -146,8 +146,8 @@ static Coroutine *coroutine_new(void)
abort();
}
- co = qemu_mallocz(sizeof(*co));
- co->stack = qemu_malloc(stack_size);
+ co = g_malloc0(sizeof(*co));
+ co->stack = g_malloc(stack_size);
co->base.entry_arg = &old_env; /* stash away our jmp_buf */
uc.uc_link = &old_uc;
@@ -194,8 +194,8 @@ void qemu_coroutine_delete(Coroutine *co_)
return;
}
- qemu_free(co->stack);
- qemu_free(co);
+ g_free(co->stack);
+ g_free(co);
}
CoroutineAction qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
diff --git a/coroutine-win32.c b/coroutine-win32.c
index 0e2944847..4179609ee 100644
--- a/coroutine-win32.c
+++ b/coroutine-win32.c
@@ -64,7 +64,7 @@ Coroutine *qemu_coroutine_new(void)
const size_t stack_size = 1 << 20;
CoroutineWin32 *co;
- co = qemu_mallocz(sizeof(*co));
+ co = g_malloc0(sizeof(*co));
co->fiber = CreateFiber(stack_size, coroutine_trampoline, &co->base);
return &co->base;
}
@@ -74,7 +74,7 @@ void qemu_coroutine_delete(Coroutine *co_)
CoroutineWin32 *co = DO_UPCAST(CoroutineWin32, base, co_);
DeleteFiber(co->fiber);
- qemu_free(co);
+ g_free(co);
}
Coroutine *qemu_coroutine_self(void)
diff --git a/cpus.c b/cpus.c
index 6bf4e3f00..c996ac5fd 100644
--- a/cpus.c
+++ b/cpus.c
@@ -968,8 +968,8 @@ static void qemu_tcg_init_vcpu(void *_env)
/* share a single thread for all cpus with TCG */
if (!tcg_cpu_thread) {
- env->thread = qemu_mallocz(sizeof(QemuThread));
- env->halt_cond = qemu_mallocz(sizeof(QemuCond));
+ env->thread = g_malloc0(sizeof(QemuThread));
+ env->halt_cond = g_malloc0(sizeof(QemuCond));
qemu_cond_init(env->halt_cond);
qemu_thread_create(env->thread, qemu_tcg_cpu_thread_fn, env);
while (env->created == 0) {
@@ -985,8 +985,8 @@ static void qemu_tcg_init_vcpu(void *_env)
static void qemu_kvm_start_vcpu(CPUState *env)
{
- env->thread = qemu_mallocz(sizeof(QemuThread));
- env->halt_cond = qemu_mallocz(sizeof(QemuCond));
+ env->thread = g_malloc0(sizeof(QemuThread));
+ env->halt_cond = g_malloc0(sizeof(QemuCond));
qemu_cond_init(env->halt_cond);
qemu_thread_create(env->thread, qemu_kvm_cpu_thread_fn, env);
while (env->created == 0) {
diff --git a/cris-dis.c b/cris-dis.c
index 5fa67d9f2..5b8e90b2c 100644
--- a/cris-dis.c
+++ b/cris-dis.c
@@ -1396,32 +1396,32 @@ get_opcode_entry (unsigned int insn,
/* Allocate and clear the opcode-table. */
if (opc_table == NULL)
{
- opc_table = qemu_malloc (65536 * sizeof (opc_table[0]));
+ opc_table = g_malloc (65536 * sizeof (opc_table[0]));
memset (opc_table, 0, 65536 * sizeof (const struct cris_opcode *));
dip_prefixes
- = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
+ = g_malloc (65536 * sizeof (const struct cris_opcode **));
memset (dip_prefixes, 0, 65536 * sizeof (dip_prefixes[0]));
bdapq_m1_prefixes
- = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
+ = g_malloc (65536 * sizeof (const struct cris_opcode **));
memset (bdapq_m1_prefixes, 0, 65536 * sizeof (bdapq_m1_prefixes[0]));
bdapq_m2_prefixes
- = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
+ = g_malloc (65536 * sizeof (const struct cris_opcode **));
memset (bdapq_m2_prefixes, 0, 65536 * sizeof (bdapq_m2_prefixes[0]));
bdapq_m4_prefixes
- = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
+ = g_malloc (65536 * sizeof (const struct cris_opcode **));
memset (bdapq_m4_prefixes, 0, 65536 * sizeof (bdapq_m4_prefixes[0]));
rest_prefixes
- = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
+ = g_malloc (65536 * sizeof (const struct cris_opcode **));
memset (rest_prefixes, 0, 65536 * sizeof (rest_prefixes[0]));
}
diff --git a/cursor.c b/cursor.c
index dfb9eefaa..efc591702 100644
--- a/cursor.c
+++ b/cursor.c
@@ -98,7 +98,7 @@ QEMUCursor *cursor_alloc(int width, int height)
QEMUCursor *c;
int datasize = width * height * sizeof(uint32_t);
- c = qemu_mallocz(sizeof(QEMUCursor) + datasize);
+ c = g_malloc0(sizeof(QEMUCursor) + datasize);
c->width = width;
c->height = height;
c->refcount = 1;
@@ -117,7 +117,7 @@ void cursor_put(QEMUCursor *c)
c->refcount--;
if (c->refcount)
return;
- qemu_free(c);
+ g_free(c);
}
int cursor_get_mono_bpl(QEMUCursor *c)
diff --git a/cutils.c b/cutils.c
index 28049e069..f2bcf20ff 100644
--- a/cutils.c
+++ b/cutils.c
@@ -136,7 +136,7 @@ int qemu_fdatasync(int fd)
void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint)
{
- qiov->iov = qemu_malloc(alloc_hint * sizeof(struct iovec));
+ qiov->iov = g_malloc(alloc_hint * sizeof(struct iovec));
qiov->niov = 0;
qiov->nalloc = alloc_hint;
qiov->size = 0;
@@ -160,7 +160,7 @@ void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len)
if (qiov->niov == qiov->nalloc) {
qiov->nalloc = 2 * qiov->nalloc + 1;
- qiov->iov = qemu_realloc(qiov->iov, qiov->nalloc * sizeof(struct iovec));
+ qiov->iov = g_realloc(qiov->iov, qiov->nalloc * sizeof(struct iovec));
}
qiov->iov[qiov->niov].iov_base = base;
qiov->iov[qiov->niov].iov_len = len;
@@ -217,7 +217,7 @@ void qemu_iovec_destroy(QEMUIOVector *qiov)
{
assert(qiov->nalloc != -1);
- qemu_free(qiov->iov);
+ g_free(qiov->iov);
}
void qemu_iovec_reset(QEMUIOVector *qiov)
diff --git a/device_tree.c b/device_tree.c
index f5d5eb1bc..3a224d1e0 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -43,7 +43,7 @@ void *load_device_tree(const char *filename_path, int *sizep)
/* Expand to 2x size to give enough room for manipulation. */
dt_size *= 2;
/* First allocate space in qemu for device tree */
- fdt = qemu_mallocz(dt_size);
+ fdt = g_malloc0(dt_size);
dt_file_load_size = load_image(filename_path, fdt);
if (dt_file_load_size < 0) {
@@ -68,7 +68,7 @@ void *load_device_tree(const char *filename_path, int *sizep)
return fdt;
fail:
- qemu_free(fdt);
+ g_free(fdt);
return NULL;
}
diff --git a/dma-helpers.c b/dma-helpers.c
index ba7f897d4..4610ea042 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -12,7 +12,7 @@
void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint)
{
- qsg->sg = qemu_malloc(alloc_hint * sizeof(ScatterGatherEntry));
+ qsg->sg = g_malloc(alloc_hint * sizeof(ScatterGatherEntry));
qsg->nsg = 0;
qsg->nalloc = alloc_hint;
qsg->size = 0;
@@ -23,7 +23,7 @@ void qemu_sglist_add(QEMUSGList *qsg, target_phys_addr_t base,
{
if (qsg->nsg == qsg->nalloc) {
qsg->nalloc = 2 * qsg->nalloc + 1;
- qsg->sg = qemu_realloc(qsg->sg, qsg->nalloc * sizeof(ScatterGatherEntry));
+ qsg->sg = g_realloc(qsg->sg, qsg->nalloc * sizeof(ScatterGatherEntry));
}
qsg->sg[qsg->nsg].base = base;
qsg->sg[qsg->nsg].len = len;
@@ -33,7 +33,7 @@ void qemu_sglist_add(QEMUSGList *qsg, target_phys_addr_t base,
void qemu_sglist_destroy(QEMUSGList *qsg)
{
- qemu_free(qsg->sg);
+ g_free(qsg->sg);
}
typedef struct {
diff --git a/error.c b/error.c
index 74d7398b5..b80275261 100644
--- a/error.c
+++ b/error.c
@@ -32,7 +32,7 @@ void error_set(Error **errp, const char *fmt, ...)
return;
}
- err = qemu_mallocz(sizeof(*err));
+ err = g_malloc0(sizeof(*err));
va_start(ap, fmt);
err->obj = qobject_to_qdict(qobject_from_jsonv(fmt, &ap));
@@ -52,7 +52,7 @@ const char *error_get_pretty(Error *err)
if (err->msg == NULL) {
QString *str;
str = qerror_format(err->fmt, err->obj);
- err->msg = qemu_strdup(qstring_get_str(str));
+ err->msg = g_strdup(qstring_get_str(str));
QDECREF(str);
}
@@ -86,8 +86,8 @@ void error_free(Error *err)
{
if (err) {
QDECREF(err->obj);
- qemu_free(err->msg);
- qemu_free(err);
+ g_free(err->msg);
+ g_free(err);
}
}
@@ -133,7 +133,7 @@ void error_set_qobject(Error **errp, QObject *obj)
if (errp == NULL) {
return;
}
- err = qemu_mallocz(sizeof(*err));
+ err = g_malloc0(sizeof(*err));
err->obj = qobject_to_qdict(obj);
qobject_incref(obj);
diff --git a/exec.c b/exec.c
index 63adb189e..c1e045d32 100644
--- a/exec.c
+++ b/exec.c
@@ -352,7 +352,7 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc)
int i;
#if defined(CONFIG_USER_ONLY)
- /* We can't use qemu_malloc because it may recurse into a locked mutex. */
+ /* We can't use g_malloc because it may recurse into a locked mutex. */
# define ALLOC(P, SIZE) \
do { \
P = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, \
@@ -360,7 +360,7 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc)
} while (0)
#else
# define ALLOC(P, SIZE) \
- do { P = qemu_mallocz(SIZE); } while (0)
+ do { P = g_malloc0(SIZE); } while (0)
#endif
/* Level 1. Always allocated. */
@@ -417,7 +417,7 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc)
if (!alloc) {
return NULL;
}
- *lp = p = qemu_mallocz(sizeof(void *) * L2_SIZE);
+ *lp = p = g_malloc0(sizeof(void *) * L2_SIZE);
}
lp = p + ((index >> (i * L2_BITS)) & (L2_SIZE - 1));
}
@@ -430,7 +430,7 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc)
return NULL;
}
- *lp = pd = qemu_malloc(sizeof(PhysPageDesc) * L2_SIZE);
+ *lp = pd = g_malloc(sizeof(PhysPageDesc) * L2_SIZE);
for (i = 0; i < L2_SIZE; i++) {
pd[i].phys_offset = IO_MEM_UNASSIGNED;
@@ -558,7 +558,7 @@ static void code_gen_alloc(unsigned long tb_size)
}
}
#else
- code_gen_buffer = qemu_malloc(code_gen_buffer_size);
+ code_gen_buffer = g_malloc(code_gen_buffer_size);
map_exec(code_gen_buffer, code_gen_buffer_size);
#endif
#endif /* !USE_STATIC_CODE_GEN_BUFFER */
@@ -566,7 +566,7 @@ static void code_gen_alloc(unsigned long tb_size)
code_gen_buffer_max_size = code_gen_buffer_size -
(TCG_MAX_OP_SIZE * OPC_BUF_SIZE);
code_gen_max_blocks = code_gen_buffer_size / CODE_GEN_AVG_BLOCK_SIZE;
- tbs = qemu_malloc(code_gen_max_blocks * sizeof(TranslationBlock));
+ tbs = g_malloc(code_gen_max_blocks * sizeof(TranslationBlock));
}
/* Must be called before using the QEMU cpus. 'tb_size' is the size
@@ -701,7 +701,7 @@ void tb_free(TranslationBlock *tb)
static inline void invalidate_page_bitmap(PageDesc *p)
{
if (p->code_bitmap) {
- qemu_free(p->code_bitmap);
+ g_free(p->code_bitmap);
p->code_bitmap = NULL;
}
p->code_write_count = 0;
@@ -961,7 +961,7 @@ static void build_page_bitmap(PageDesc *p)
int n, tb_start, tb_end;
TranslationBlock *tb;
- p->code_bitmap = qemu_mallocz(TARGET_PAGE_SIZE / 8);
+ p->code_bitmap = g_malloc0(TARGET_PAGE_SIZE / 8);
tb = p->first_tb;
while (tb != NULL) {
@@ -1448,7 +1448,7 @@ int cpu_watchpoint_insert(CPUState *env, target_ulong addr, target_ulong len,
TARGET_FMT_lx ", len=" TARGET_FMT_lu "\n", addr, len);
return -EINVAL;
}
- wp = qemu_malloc(sizeof(*wp));
+ wp = g_malloc(sizeof(*wp));
wp->vaddr = addr;
wp->len_mask = len_mask;
@@ -1491,7 +1491,7 @@ void cpu_watchpoint_remove_by_ref(CPUState *env, CPUWatchpoint *watchpoint)
tlb_flush_page(env, watchpoint->vaddr);
- qemu_free(watchpoint);
+ g_free(watchpoint);
}
/* Remove all matching watchpoints. */
@@ -1513,7 +1513,7 @@ int cpu_breakpoint_insert(CPUState *env, target_ulong pc, int flags,
#if defined(TARGET_HAS_ICE)
CPUBreakpoint *bp;
- bp = qemu_malloc(sizeof(*bp));
+ bp = g_malloc(sizeof(*bp));
bp->pc = pc;
bp->flags = flags;
@@ -1560,7 +1560,7 @@ void cpu_breakpoint_remove_by_ref(CPUState *env, CPUBreakpoint *breakpoint)
breakpoint_invalidate(env, breakpoint->pc);
- qemu_free(breakpoint);
+ g_free(breakpoint);
#endif
}
@@ -2921,13 +2921,13 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,
RAMBlock *new_block, *block;
size = TARGET_PAGE_ALIGN(size);
- new_block = qemu_mallocz(sizeof(*new_block));
+ new_block = g_malloc0(sizeof(*new_block));
if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) {
char *id = dev->parent_bus->info->get_dev_path(dev);
if (id) {
snprintf(new_block->idstr, sizeof(new_block->idstr), "%s/", id);
- qemu_free(id);
+ g_free(id);
}
}
pstrcat(new_block->idstr, sizeof(new_block->idstr), name);
@@ -2984,7 +2984,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,
QLIST_INSERT_HEAD(&ram_list.blocks, new_block, next);
- ram_list.phys_dirty = qemu_realloc(ram_list.phys_dirty,
+ ram_list.phys_dirty = g_realloc(ram_list.phys_dirty,
last_ram_offset() >> TARGET_PAGE_BITS);
memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS),
0xff, size >> TARGET_PAGE_BITS);
@@ -3007,7 +3007,7 @@ void qemu_ram_free_from_ptr(ram_addr_t addr)
QLIST_FOREACH(block, &ram_list.blocks, next) {
if (addr == block->offset) {
QLIST_REMOVE(block, next);
- qemu_free(block);
+ g_free(block);
return;
}
}
@@ -3044,7 +3044,7 @@ void qemu_ram_free(ram_addr_t addr)
}
#endif
}
- qemu_free(block);
+ g_free(block);
return;
}
}
@@ -3602,7 +3602,7 @@ static subpage_t *subpage_init (target_phys_addr_t base, ram_addr_t *phys,
subpage_t *mmio;
int subpage_memory;
- mmio = qemu_mallocz(sizeof(subpage_t));
+ mmio = g_malloc0(sizeof(subpage_t));
mmio->base = base;
subpage_memory = cpu_register_io_memory(subpage_read, subpage_write, mmio,
@@ -3708,7 +3708,7 @@ static CPUWriteMemoryFunc * const swapendian_writefn[3]={
static void swapendian_init(int io_index)
{
- SwapEndianContainer *c = qemu_malloc(sizeof(SwapEndianContainer));
+ SwapEndianContainer *c = g_malloc(sizeof(SwapEndianContainer));
int i;
/* Swap mmio for big endian targets */
@@ -3726,7 +3726,7 @@ static void swapendian_init(int io_index)
static void swapendian_del(int io_index)
{
if (io_mem_read[io_index][0] == swapendian_readfn[0]) {
- qemu_free(io_mem_opaque[io_index]);
+ g_free(io_mem_opaque[io_index]);
}
}
@@ -3828,11 +3828,11 @@ static void io_mem_init(void)
static void memory_map_init(void)
{
- system_memory = qemu_malloc(sizeof(*system_memory));
+ system_memory = g_malloc(sizeof(*system_memory));
memory_region_init(system_memory, "system", INT64_MAX);
set_system_memory_map(system_memory);
- system_io = qemu_malloc(sizeof(*system_io));
+ system_io = g_malloc(sizeof(*system_io));
memory_region_init(system_io, "io", 65536);
set_system_io_map(system_io);
}
@@ -4048,7 +4048,7 @@ static QLIST_HEAD(map_client_list, MapClient) map_client_list
void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque))
{
- MapClient *client = qemu_malloc(sizeof(*client));
+ MapClient *client = g_malloc(sizeof(*client));
client->opaque = opaque;
client->callback = callback;
@@ -4061,7 +4061,7 @@ void cpu_unregister_map_client(void *_client)
MapClient *client = (MapClient *)_client;
QLIST_REMOVE(client, link);
- qemu_free(client);
+ g_free(client);
}
static void cpu_notify_map_clients(void)
diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c
index 0b332907b..336d7e40d 100644
--- a/fsdev/qemu-fsdev.c
+++ b/fsdev/qemu-fsdev.c
@@ -65,11 +65,11 @@ int qemu_fsdev_add(QemuOpts *opts)
return -1;
}
- fsle = qemu_malloc(sizeof(*fsle));
+ fsle = g_malloc(sizeof(*fsle));
- fsle->fse.fsdev_id = qemu_strdup(fsdev_id);
- fsle->fse.path = qemu_strdup(path);
- fsle->fse.security_model = qemu_strdup(sec_model);
+ fsle->fse.fsdev_id = g_strdup(fsdev_id);
+ fsle->fse.path = g_strdup(path);
+ fsle->fse.security_model = g_strdup(sec_model);
fsle->fse.ops = FsTypes[i].ops;
QTAILQ_INSERT_TAIL(&fstype_entries, fsle, next);
diff --git a/gdbstub.c b/gdbstub.c
index 27b0cfa81..2f0206d18 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1668,7 +1668,7 @@ void gdb_register_coprocessor(CPUState * env,
GDBRegisterState **p;
static int last_reg = NUM_CORE_REGS;
- s = (GDBRegisterState *)qemu_mallocz(sizeof(GDBRegisterState));
+ s = (GDBRegisterState *)g_malloc0(sizeof(GDBRegisterState));
s->base_reg = last_reg;
s->num_regs = num_regs;
s->get_reg = get_reg;
@@ -2606,7 +2606,7 @@ static void gdb_accept(void)
val = 1;
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val));
- s = qemu_mallocz(sizeof(GDBState));
+ s = g_malloc0(sizeof(GDBState));
s->c_cpu = first_cpu;
s->g_cpu = first_cpu;
s->fd = fd;
@@ -2774,13 +2774,13 @@ int gdbserver_start(const char *device)
s = gdbserver_state;
if (!s) {
- s = qemu_mallocz(sizeof(GDBState));
+ s = g_malloc0(sizeof(GDBState));
gdbserver_state = s;
qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL);
/* Initialize a monitor terminal for gdb */
- mon_chr = qemu_mallocz(sizeof(*mon_chr));
+ mon_chr = g_malloc0(sizeof(*mon_chr));
mon_chr->chr_write = gdb_monitor_write;
monitor_init(mon_chr, 0);
} else {
diff --git a/hw/9pfs/cofs.c b/hw/9pfs/cofs.c
index 473ce5356..1f1063254 100644
--- a/hw/9pfs/cofs.c
+++ b/hw/9pfs/cofs.c
@@ -22,7 +22,7 @@ int v9fs_co_readlink(V9fsState *s, V9fsString *path, V9fsString *buf)
int err;
ssize_t len;
- buf->data = qemu_malloc(PATH_MAX);
+ buf->data = g_malloc(PATH_MAX);
v9fs_co_run_in_worker(
{
len = s->ops->readlink(&s->ctx, path->data,
@@ -36,7 +36,7 @@ int v9fs_co_readlink(V9fsState *s, V9fsString *path, V9fsString *buf)
}
});
if (err) {
- qemu_free(buf->data);
+ g_free(buf->data);
buf->data = NULL;
buf->size = 0;
}
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index f4bf47187..94660024d 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -36,12 +36,12 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
struct virtio_9p_config *cfg;
V9fsState *s = to_virtio_9p(vdev);
- cfg = qemu_mallocz(sizeof(struct virtio_9p_config) +
+ cfg = g_malloc0(sizeof(struct virtio_9p_config) +
s->tag_len);
stw_raw(&cfg->tag_len, s->tag_len);
memcpy(cfg->tag, s->tag, s->tag_len);
memcpy(config, cfg, s->config_size);
- qemu_free(cfg);
+ g_free(cfg);
}
VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
@@ -114,13 +114,13 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
exit(1);
}
- s->ctx.fs_root = qemu_strdup(fse->path);
+ s->ctx.fs_root = g_strdup(fse->path);
len = strlen(conf->tag);
if (len > MAX_TAG_LEN) {
len = MAX_TAG_LEN;
}
/* s->tag is non-NULL terminated string */
- s->tag = qemu_malloc(len);
+ s->tag = g_malloc(len);
memcpy(s->tag, conf->tag, len);
s->tag_len = len;
s->ctx.uid = -1;
diff --git a/hw/9pfs/virtio-9p-xattr.c b/hw/9pfs/virtio-9p-xattr.c
index bde0b7fb4..7f08f6e17 100644
--- a/hw/9pfs/virtio-9p-xattr.c
+++ b/hw/9pfs/virtio-9p-xattr.c
@@ -79,7 +79,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path,
}
/* Now fetch the xattr and find the actual size */
- orig_value = qemu_malloc(xattr_len);
+ orig_value = g_malloc(xattr_len);
xattr_len = llistxattr(rpath(ctx, path, buffer), orig_value, xattr_len);
/* store the orig pointer */
@@ -111,7 +111,7 @@ next_entry:
}
err_out:
- qemu_free(orig_value_start);
+ g_free(orig_value_start);
return size;
}
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index f2193d696..eb3363656 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -239,7 +239,7 @@ static void v9fs_string_init(V9fsString *str)
static void v9fs_string_free(V9fsString *str)
{
- qemu_free(str->data);
+ g_free(str->data);
str->data = NULL;
str->size = 0;
}
@@ -338,7 +338,7 @@ v9fs_string_alloc_printf(char **strp, const char *fmt, va_list ap)
}
alloc_print:
- *strp = qemu_malloc((len + 1) * sizeof(**strp));
+ *strp = g_malloc((len + 1) * sizeof(**strp));
return vsprintf(*strp, fmt, ap);
}
@@ -408,7 +408,7 @@ static V9fsFidState *alloc_fid(V9fsState *s, int32_t fid)
return NULL;
}
- f = qemu_mallocz(sizeof(V9fsFidState));
+ f = g_malloc0(sizeof(V9fsFidState));
f->fid = fid;
f->fid_type = P9_FID_NONE;
@@ -448,7 +448,7 @@ free_out:
v9fs_string_free(&fidp->fs.xattr.name);
free_value:
if (fidp->fs.xattr.value) {
- qemu_free(fidp->fs.xattr.value);
+ g_free(fidp->fs.xattr.value);
}
return retval;
}
@@ -479,7 +479,7 @@ static int free_fid(V9fsState *s, int32_t fid)
retval = v9fs_xattr_fid_clunk(s, fidp);
}
v9fs_string_free(&fidp->path);
- qemu_free(fidp);
+ g_free(fidp);
return retval;
}
@@ -685,7 +685,7 @@ static size_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
V9fsString *str = va_arg(ap, V9fsString *);
offset += pdu_unmarshal(pdu, offset, "w", &str->size);
/* FIXME: sanity check str->size */
- str->data = qemu_malloc(str->size + 1);
+ str->data = g_malloc(str->size + 1);
offset += pdu_unpack(str->data, pdu, offset, str->size);
str->data[str->size] = 0;
break;
@@ -1209,7 +1209,7 @@ static void v9fs_stat_post_lstat(V9fsState *s, V9fsStatState *vs, int err)
out:
complete_pdu(s, vs->pdu, err);
v9fs_stat_free(&vs->v9stat);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_stat(void *opaque)
@@ -1220,7 +1220,7 @@ static void v9fs_stat(void *opaque)
V9fsStatState *vs;
ssize_t err = 0;
- vs = qemu_malloc(sizeof(*vs));
+ vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
@@ -1241,7 +1241,7 @@ static void v9fs_stat(void *opaque)
out:
complete_pdu(s, vs->pdu, err);
v9fs_stat_free(&vs->v9stat);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_getattr(void *opaque)
@@ -1379,8 +1379,8 @@ static void v9fs_walk_complete(V9fsState *s, V9fsWalkState *vs, int err)
v9fs_string_free(&vs->wnames[vs->name_idx]);
}
- qemu_free(vs->wnames);
- qemu_free(vs->qids);
+ g_free(vs->wnames);
+ g_free(vs->qids);
}
}
@@ -1463,7 +1463,7 @@ static void v9fs_walk(void *opaque)
int err = 0;
int i;
- vs = qemu_malloc(sizeof(*vs));
+ vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->wnames = NULL;
vs->qids = NULL;
@@ -1473,9 +1473,9 @@ static void v9fs_walk(void *opaque)
&newfid, &vs->nwnames);
if (vs->nwnames && vs->nwnames <= P9_MAXWELEM) {
- vs->wnames = qemu_mallocz(sizeof(vs->wnames[0]) * vs->nwnames);
+ vs->wnames = g_malloc0(sizeof(vs->wnames[0]) * vs->nwnames);
- vs->qids = qemu_mallocz(sizeof(vs->qids[0]) * vs->nwnames);
+ vs->qids = g_malloc0(sizeof(vs->qids[0]) * vs->nwnames);
for (i = 0; i < vs->nwnames; i++) {
vs->offset += pdu_unmarshal(vs->pdu, vs->offset, "s",
@@ -1568,7 +1568,7 @@ static void v9fs_open_post_opendir(V9fsState *s, V9fsOpenState *vs, int err)
err = vs->offset;
out:
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
@@ -1578,7 +1578,7 @@ static void v9fs_open_post_getiounit(V9fsState *s, V9fsOpenState *vs)
vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, vs->iounit);
err = vs->offset;
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_open_post_open(V9fsState *s, V9fsOpenState *vs, int err)
@@ -1593,7 +1593,7 @@ static void v9fs_open_post_open(V9fsState *s, V9fsOpenState *vs, int err)
return;
out:
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_open_post_lstat(V9fsState *s, V9fsOpenState *vs, int err)
@@ -1625,7 +1625,7 @@ static void v9fs_open_post_lstat(V9fsState *s, V9fsOpenState *vs, int err)
return;
out:
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_open(void *opaque)
@@ -1636,7 +1636,7 @@ static void v9fs_open(void *opaque)
V9fsOpenState *vs;
ssize_t err = 0;
- vs = qemu_malloc(sizeof(*vs));
+ vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
vs->mode = 0;
@@ -1661,7 +1661,7 @@ static void v9fs_open(void *opaque)
return;
out:
complete_pdu(s, pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_post_lcreate(V9fsState *s, V9fsLcreateState *vs, int err)
@@ -1683,7 +1683,7 @@ static void v9fs_post_lcreate(V9fsState *s, V9fsLcreateState *vs, int err)
complete_pdu(s, vs->pdu, err);
v9fs_string_free(&vs->name);
v9fs_string_free(&vs->fullname);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_lcreate_post_get_iounit(V9fsState *s, V9fsLcreateState *vs,
@@ -1724,7 +1724,7 @@ static void v9fs_lcreate(void *opaque)
V9fsLcreateState *vs;
ssize_t err = 0;
- vs = qemu_malloc(sizeof(*vs));
+ vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
@@ -1753,7 +1753,7 @@ static void v9fs_lcreate(void *opaque)
out:
complete_pdu(s, vs->pdu, err);
v9fs_string_free(&vs->name);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_post_do_fsync(V9fsState *s, V9fsPDU *pdu, int err)
@@ -1820,7 +1820,7 @@ out:
complete_pdu(s, vs->pdu, err);
v9fs_stat_free(&vs->v9stat);
v9fs_string_free(&vs->name);
- qemu_free(vs);
+ g_free(vs);
return;
}
@@ -1874,7 +1874,7 @@ static void v9fs_read_post_readdir(V9fsState *s, V9fsReadState *vs, ssize_t err)
vs->offset += vs->count;
err = vs->offset;
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
return;
}
@@ -1925,7 +1925,7 @@ static void v9fs_read_post_preadv(V9fsState *s, V9fsReadState *vs, ssize_t err)
out:
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_xattr_read(V9fsState *s, V9fsReadState *vs)
@@ -1950,7 +1950,7 @@ static void v9fs_xattr_read(V9fsState *s, V9fsReadState *vs)
read_count);
err = vs->offset;
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_read(void *opaque)
@@ -1961,7 +1961,7 @@ static void v9fs_read(void *opaque)
V9fsReadState *vs;
ssize_t err = 0;
- vs = qemu_malloc(sizeof(*vs));
+ vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
vs->total = 0;
@@ -2006,7 +2006,7 @@ static void v9fs_read(void *opaque)
}
out:
complete_pdu(s, pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static size_t v9fs_readdir_data_size(V9fsString *name)
@@ -2138,7 +2138,7 @@ static void v9fs_write_post_pwritev(V9fsState *s, V9fsWriteState *vs,
err = vs->offset;
out:
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_xattr_write(V9fsState *s, V9fsWriteState *vs)
@@ -2180,7 +2180,7 @@ static void v9fs_xattr_write(V9fsState *s, V9fsWriteState *vs)
}
out:
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_write(void *opaque)
@@ -2191,7 +2191,7 @@ static void v9fs_write(void *opaque)
V9fsWriteState *vs;
ssize_t err;
- vs = qemu_malloc(sizeof(*vs));
+ vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
@@ -2235,7 +2235,7 @@ static void v9fs_write(void *opaque)
return;
out:
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_create_post_getiounit(V9fsState *s, V9fsCreateState *vs)
@@ -2251,7 +2251,7 @@ static void v9fs_create_post_getiounit(V9fsState *s, V9fsCreateState *vs)
v9fs_string_free(&vs->name);
v9fs_string_free(&vs->extension);
v9fs_string_free(&vs->fullname);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
@@ -2266,7 +2266,7 @@ static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
v9fs_string_free(&vs->name);
v9fs_string_free(&vs->extension);
v9fs_string_free(&vs->fullname);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_create_post_perms(V9fsState *s, V9fsCreateState *vs, int err)
@@ -2426,7 +2426,7 @@ static void v9fs_create(void *opaque)
V9fsCreateState *vs;
int err = 0;
- vs = qemu_malloc(sizeof(*vs));
+ vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
@@ -2452,7 +2452,7 @@ out:
complete_pdu(s, vs->pdu, err);
v9fs_string_free(&vs->name);
v9fs_string_free(&vs->extension);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_post_symlink(V9fsState *s, V9fsSymlinkState *vs, int err)
@@ -2468,7 +2468,7 @@ static void v9fs_post_symlink(V9fsState *s, V9fsSymlinkState *vs, int err)
v9fs_string_free(&vs->name);
v9fs_string_free(&vs->symname);
v9fs_string_free(&vs->fullname);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_symlink_post_do_symlink(V9fsState *s, V9fsSymlinkState *vs,
@@ -2491,7 +2491,7 @@ static void v9fs_symlink(void *opaque)
int err = 0;
gid_t gid;
- vs = qemu_malloc(sizeof(*vs));
+ vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
@@ -2517,7 +2517,7 @@ out:
complete_pdu(s, vs->pdu, err);
v9fs_string_free(&vs->name);
v9fs_string_free(&vs->symname);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_flush(void *opaque)
@@ -2605,7 +2605,7 @@ static void v9fs_wstat_post_truncate(V9fsState *s, V9fsWstatState *vs, int err)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_wstat_post_rename(V9fsState *s, V9fsWstatState *vs, int err)
@@ -2624,7 +2624,7 @@ static void v9fs_wstat_post_rename(V9fsState *s, V9fsWstatState *vs, int err)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static int v9fs_complete_rename(V9fsState *s, V9fsFidState *fidp,
@@ -2643,7 +2643,7 @@ static int v9fs_complete_rename(V9fsState *s, V9fsFidState *fidp,
}
BUG_ON(dirfidp->fid_type != P9_FID_NONE);
- new_name = qemu_mallocz(dirfidp->path.size + name->size + 2);
+ new_name = g_malloc0(dirfidp->path.size + name->size + 2);
strcpy(new_name, dirfidp->path.data);
strcat(new_name, "/");
@@ -2656,7 +2656,7 @@ static int v9fs_complete_rename(V9fsState *s, V9fsFidState *fidp,
} else {
end = old_name;
}
- new_name = qemu_mallocz(end - old_name + name->size + 1);
+ new_name = g_malloc0(end - old_name + name->size + 1);
strncat(new_name, old_name, end - old_name);
strncat(new_name + (end - old_name), name->data, name->size);
@@ -2710,7 +2710,7 @@ static void v9fs_wstat_post_chown(V9fsState *s, V9fsWstatState *vs, int err)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_rename(void *opaque)
@@ -2760,7 +2760,7 @@ static void v9fs_wstat_post_utime(V9fsState *s, V9fsWstatState *vs, int err)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_wstat_post_chmod(V9fsState *s, V9fsWstatState *vs, int err)
@@ -2795,7 +2795,7 @@ static void v9fs_wstat_post_chmod(V9fsState *s, V9fsWstatState *vs, int err)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_wstat_post_fsync(V9fsState *s, V9fsWstatState *vs, int err)
@@ -2805,7 +2805,7 @@ static void v9fs_wstat_post_fsync(V9fsState *s, V9fsWstatState *vs, int err)
}
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_wstat_post_lstat(V9fsState *s, V9fsWstatState *vs, int err)
@@ -2836,7 +2836,7 @@ static void v9fs_wstat_post_lstat(V9fsState *s, V9fsWstatState *vs, int err)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static void v9fs_wstat(void *opaque)
@@ -2847,7 +2847,7 @@ static void v9fs_wstat(void *opaque)
V9fsWstatState *vs;
int err = 0;
- vs = qemu_malloc(sizeof(*vs));
+ vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
@@ -2878,7 +2878,7 @@ static void v9fs_wstat(void *opaque)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
- qemu_free(vs);
+ g_free(vs);
}
static int v9fs_fill_statfs(V9fsState *s, V9fsPDU *pdu, struct statfs *stbuf)
@@ -3014,11 +3014,11 @@ static void v9fs_lock(void *opaque)
int32_t fid, err = 0;
V9fsLockState *vs;
- vs = qemu_mallocz(sizeof(*vs));
+ vs = g_malloc0(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
- vs->flock = qemu_malloc(sizeof(*vs->flock));
+ vs->flock = g_malloc(sizeof(*vs->flock));
pdu_unmarshal(vs->pdu, vs->offset, "dbdqqds", &fid, &vs->flock->type,
&vs->flock->flags, &vs->flock->start, &vs->flock->length,
&vs->flock->proc_id, &vs->flock->client_id);
@@ -3045,8 +3045,8 @@ static void v9fs_lock(void *opaque)
out:
vs->offset += pdu_marshal(vs->pdu, vs->offset, "b", vs->status);
complete_pdu(s, vs->pdu, err);
- qemu_free(vs->flock);
- qemu_free(vs);
+ g_free(vs->flock);
+ g_free(vs);
}
/*
@@ -3061,11 +3061,11 @@ static void v9fs_getlock(void *opaque)
int32_t fid, err = 0;
V9fsGetlockState *vs;
- vs = qemu_mallocz(sizeof(*vs));
+ vs = g_malloc0(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
- vs->glock = qemu_malloc(sizeof(*vs->glock));
+ vs->glock = g_malloc(sizeof(*vs->glock));
pdu_unmarshal(vs->pdu, vs->offset, "dbqqds", &fid, &vs->glock->type,
&vs->glock->start, &vs->glock->length, &vs->glock->proc_id,
&vs->glock->client_id);
@@ -3087,8 +3087,8 @@ static void v9fs_getlock(void *opaque)
&vs->glock->client_id);
out:
complete_pdu(s, vs->pdu, err);
- qemu_free(vs->glock);
- qemu_free(vs);
+ g_free(vs->glock);
+ g_free(vs);
}
static void v9fs_mkdir(void *opaque)
@@ -3171,7 +3171,7 @@ static void v9fs_xattrwalk(void *opaque)
xattr_fidp->fid_type = P9_FID_XATTR;
xattr_fidp->fs.xattr.copied_len = -1;
if (size) {
- xattr_fidp->fs.xattr.value = qemu_malloc(size);
+ xattr_fidp->fs.xattr.value = g_malloc(size);
err = v9fs_co_llistxattr(s, &xattr_fidp->path,
xattr_fidp->fs.xattr.value,
xattr_fidp->fs.xattr.len);
@@ -3201,7 +3201,7 @@ static void v9fs_xattrwalk(void *opaque)
xattr_fidp->fid_type = P9_FID_XATTR;
xattr_fidp->fs.xattr.copied_len = -1;
if (size) {
- xattr_fidp->fs.xattr.value = qemu_malloc(size);
+ xattr_fidp->fs.xattr.value = g_malloc(size);
err = v9fs_co_lgetxattr(s, &xattr_fidp->path,
&name, xattr_fidp->fs.xattr.value,
xattr_fidp->fs.xattr.len);
@@ -3248,7 +3248,7 @@ static void v9fs_xattrcreate(void *opaque)
v9fs_string_init(&xattr_fidp->fs.xattr.name);
v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
if (size) {
- xattr_fidp->fs.xattr.value = qemu_malloc(size);
+ xattr_fidp->fs.xattr.value = g_malloc(size);
} else {
xattr_fidp->fs.xattr.value = NULL;
}
diff --git a/hw/acpi.c b/hw/acpi.c
index 79ec66c14..d04b96597 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -100,13 +100,13 @@ int acpi_table_add(const char *t)
if (!acpi_tables) {
allen = sizeof(uint16_t);
- acpi_tables = qemu_mallocz(allen);
+ acpi_tables = g_malloc0(allen);
} else {
allen = acpi_tables_len;
}
start = allen;
- acpi_tables = qemu_realloc(acpi_tables, start + ACPI_TABLE_HDR_SIZE);
+ acpi_tables = g_realloc(acpi_tables, start + ACPI_TABLE_HDR_SIZE);
allen += has_header ? ACPI_TABLE_PFX_SIZE : ACPI_TABLE_HDR_SIZE;
/* now read in the data files, reallocating buffer as needed */
@@ -125,7 +125,7 @@ int acpi_table_add(const char *t)
if (r == 0) {
break;
} else if (r > 0) {
- acpi_tables = qemu_realloc(acpi_tables, allen + r);
+ acpi_tables = g_realloc(acpi_tables, allen + r);
memcpy(acpi_tables + allen, data, r);
allen += r;
} else if (errno != EINTR) {
@@ -379,8 +379,8 @@ void acpi_pm1_cnt_reset(ACPIPM1CNT *pm1_cnt)
void acpi_gpe_init(ACPIGPE *gpe, uint8_t len)
{
gpe->len = len;
- gpe->sts = qemu_mallocz(len / 2);
- gpe->en = qemu_mallocz(len / 2);
+ gpe->sts = g_malloc0(len / 2);
+ gpe->en = g_malloc0(len / 2);
}
void acpi_gpe_blk(ACPIGPE *gpe, uint32_t blk)
diff --git a/hw/adb.c b/hw/adb.c
index 7499cdcef..8dedbf819 100644
--- a/hw/adb.c
+++ b/hw/adb.c
@@ -290,7 +290,7 @@ void adb_kbd_init(ADBBusState *bus)
{
ADBDevice *d;
KBDState *s;
- s = qemu_mallocz(sizeof(KBDState));
+ s = g_malloc0(sizeof(KBDState));
d = adb_register_device(bus, ADB_KEYBOARD, adb_kbd_request,
adb_kbd_reset, s);
qemu_add_kbd_event_handler(adb_kbd_put_keycode, d);
@@ -447,7 +447,7 @@ void adb_mouse_init(ADBBusState *bus)
ADBDevice *d;
MouseState *s;
- s = qemu_mallocz(sizeof(MouseState));
+ s = g_malloc0(sizeof(MouseState));
d = adb_register_device(bus, ADB_MOUSE, adb_mouse_request,
adb_mouse_reset, s);
qemu_add_mouse_event_handler(adb_mouse_event, d, 0, "QEMU ADB Mouse");
diff --git a/hw/adlib.c b/hw/adlib.c
index 4d76d57a1..c1c46e357 100644
--- a/hw/adlib.c
+++ b/hw/adlib.c
@@ -268,7 +268,7 @@ static void Adlib_fini (AdlibState *s)
#endif
if (s->mixbuf) {
- qemu_free (s->mixbuf);
+ g_free (s->mixbuf);
}
s->active = 0;
@@ -323,7 +323,7 @@ int Adlib_init (qemu_irq *pic)
}
s->samples = AUD_get_buffer_size_out (s->voice) >> SHIFT;
- s->mixbuf = qemu_mallocz (s->samples << SHIFT);
+ s->mixbuf = g_malloc0 (s->samples << SHIFT);
register_ioport_read (0x388, 4, 1, adlib_read, s);
register_ioport_write (0x388, 4, 1, adlib_write, s);
diff --git a/hw/applesmc.c b/hw/applesmc.c
index 23ed3287b..c47b59274 100644
--- a/hw/applesmc.c
+++ b/hw/applesmc.c
@@ -170,7 +170,7 @@ static void applesmc_add_key(struct AppleSMCStatus *s, const char *key,
{
struct AppleSMCData *def;
- def = qemu_mallocz(sizeof(struct AppleSMCData));
+ def = g_malloc0(sizeof(struct AppleSMCData));
def->key = key;
def->len = len;
def->data = data;
diff --git a/hw/arm_timer.c b/hw/arm_timer.c
index fd9448f05..f2832f9c3 100644
--- a/hw/arm_timer.c
+++ b/hw/arm_timer.c
@@ -159,7 +159,7 @@ static arm_timer_state *arm_timer_init(uint32_t freq)
arm_timer_state *s;
QEMUBH *bh;
- s = (arm_timer_state *)qemu_mallocz(sizeof(arm_timer_state));
+ s = (arm_timer_state *)g_malloc0(sizeof(arm_timer_state));
s->freq = freq;
s->control = TIMER_CTRL_IE;
diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c
index d9002a5e2..06200e257 100644
--- a/hw/axis_dev88.c
+++ b/hw/axis_dev88.c
@@ -315,7 +315,7 @@ void axisdev88_init (ram_addr_t ram_size,
}
/* Add the two ethernet blocks. */
- dma_eth = qemu_mallocz(sizeof dma_eth[0] * 4); /* Allocate 4 channels. */
+ dma_eth = g_malloc0(sizeof dma_eth[0] * 4); /* Allocate 4 channels. */
etraxfs_eth_init(&nd_table[0], 0x30034000, 1, &dma_eth[0], &dma_eth[1]);
if (nb_nics > 1) {
etraxfs_eth_init(&nd_table[1], 0x30036000, 2, &dma_eth[2], &dma_eth[3]);
diff --git a/hw/baum.c b/hw/baum.c
index 33a22a73d..26beeaf7e 100644
--- a/hw/baum.c
+++ b/hw/baum.c
@@ -559,7 +559,7 @@ static void baum_chr_read(void *opaque)
if (ret == -1 && (brlapi_errno != BRLAPI_ERROR_LIBCERR || errno != EINTR)) {
brlapi_perror("baum: brlapi_readKey");
brlapi__closeConnection(baum->brlapi);
- qemu_free(baum->brlapi);
+ g_free(baum->brlapi);
baum->brlapi = NULL;
}
}
@@ -571,9 +571,9 @@ static void baum_close(struct CharDriverState *chr)
qemu_free_timer(baum->cellCount_timer);
if (baum->brlapi) {
brlapi__closeConnection(baum->brlapi);
- qemu_free(baum->brlapi);
+ g_free(baum->brlapi);
}
- qemu_free(baum);
+ g_free(baum);
}
int chr_baum_init(QemuOpts *opts, CharDriverState **_chr)
@@ -586,8 +586,8 @@ int chr_baum_init(QemuOpts *opts, CharDriverState **_chr)
#endif
int tty;
- baum = qemu_mallocz(sizeof(BaumDriverState));
- baum->chr = chr = qemu_mallocz(sizeof(CharDriverState));
+ baum = g_malloc0(sizeof(BaumDriverState));
+ baum->chr = chr = g_malloc0(sizeof(CharDriverState));
chr->opaque = baum;
chr->chr_write = baum_write;
@@ -595,7 +595,7 @@ int chr_baum_init(QemuOpts *opts, CharDriverState **_chr)
chr->chr_accept_input = baum_accept_input;
chr->chr_close = baum_close;
- handle = qemu_mallocz(brlapi_getHandleSize());
+ handle = g_malloc0(brlapi_getHandleSize());
baum->brlapi = handle;
baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL);
@@ -636,8 +636,8 @@ fail:
qemu_free_timer(baum->cellCount_timer);
brlapi__closeConnection(handle);
fail_handle:
- qemu_free(handle);
- qemu_free(chr);
- qemu_free(baum);
+ g_free(handle);
+ g_free(chr);
+ g_free(baum);
return -EIO;
}
diff --git a/hw/bitbang_i2c.c b/hw/bitbang_i2c.c
index 53e9c5c4c..431359d61 100644
--- a/hw/bitbang_i2c.c
+++ b/hw/bitbang_i2c.c
@@ -171,7 +171,7 @@ bitbang_i2c_interface *bitbang_i2c_init(i2c_bus *bus)
{
bitbang_i2c_interface *s;
- s = qemu_mallocz(sizeof(bitbang_i2c_interface));
+ s = g_malloc0(sizeof(bitbang_i2c_interface));
s->bus = bus;
s->last_data = 1;
diff --git a/hw/blizzard.c b/hw/blizzard.c
index c5245504a..b2c1b2284 100644
--- a/hw/blizzard.c
+++ b/hw/blizzard.c
@@ -188,7 +188,7 @@ static int blizzard_transfer_setup(BlizzardState *s)
s->data.len = s->bpp * s->data.dx * s->data.dy;
s->data.pitch = s->data.dx;
if (s->data.len > s->data.buflen) {
- s->data.buf = qemu_realloc(s->data.buf, s->data.len);
+ s->data.buf = g_realloc(s->data.buf, s->data.len);
s->data.buflen = s->data.len;
}
s->data.ptr = s->data.buf;
@@ -953,9 +953,9 @@ static void blizzard_screen_dump(void *opaque, const char *filename) {
void *s1d13745_init(qemu_irq gpio_int)
{
- BlizzardState *s = (BlizzardState *) qemu_mallocz(sizeof(*s));
+ BlizzardState *s = (BlizzardState *) g_malloc0(sizeof(*s));
- s->fb = qemu_malloc(0x180000);
+ s->fb = g_malloc(0x180000);
s->state = graphic_console_init(blizzard_update_display,
blizzard_invalidate_display,
@@ -964,7 +964,7 @@ void *s1d13745_init(qemu_irq gpio_int)
switch (ds_get_bits_per_pixel(s->state)) {
case 0:
s->line_fn_tab[0] = s->line_fn_tab[1] =
- qemu_mallocz(sizeof(blizzard_fn_t) * 0x10);
+ g_malloc0(sizeof(blizzard_fn_t) * 0x10);
break;
case 8:
s->line_fn_tab[0] = blizzard_draw_fn_8;
diff --git a/hw/bt-hci-csr.c b/hw/bt-hci-csr.c
index d135ef479..0dcf89742 100644
--- a/hw/bt-hci-csr.c
+++ b/hw/bt-hci-csr.c
@@ -434,7 +434,7 @@ qemu_irq *csrhci_pins_get(CharDriverState *chr)
CharDriverState *uart_hci_init(qemu_irq wakeup)
{
struct csrhci_s *s = (struct csrhci_s *)
- qemu_mallocz(sizeof(struct csrhci_s));
+ g_malloc0(sizeof(struct csrhci_s));
s->chr.opaque = s;
s->chr.chr_write = csrhci_write;
diff --git a/hw/bt-hci.c b/hw/bt-hci.c
index 41df24c70..a3a7fb49e 100644
--- a/hw/bt-hci.c
+++ b/hw/bt-hci.c
@@ -721,7 +721,7 @@ static void bt_hci_connection_reject_event(struct bt_hci_s *hci,
static void bt_hci_connection_accept(struct bt_hci_s *hci,
struct bt_device_s *host)
{
- struct bt_hci_link_s *link = qemu_mallocz(sizeof(struct bt_hci_link_s));
+ struct bt_hci_link_s *link = g_malloc0(sizeof(struct bt_hci_link_s));
evt_conn_complete params;
uint16_t handle;
uint8_t status = HCI_SUCCESS;
@@ -736,7 +736,7 @@ static void bt_hci_connection_accept(struct bt_hci_s *hci,
tries);
if (!tries) {
- qemu_free(link);
+ g_free(link);
bt_hci_connection_reject(hci, host, HCI_REJECTED_LIMITED_RESOURCES);
status = HCI_NO_CONNECTION;
goto complete;
@@ -893,7 +893,7 @@ static void bt_hci_disconnect(struct bt_hci_s *hci,
/* We are the slave, we get to clean this burden */
link = (struct bt_hci_link_s *) btlink;
- qemu_free(link);
+ g_free(link);
complete:
bt_hci_lmp_link_teardown(hci, handle);
@@ -928,7 +928,7 @@ static void bt_hci_lmp_disconnect_slave(struct bt_link_s *btlink)
uint16_t handle = link->handle;
evt_disconn_complete params;
- qemu_free(link);
+ g_free(link);
bt_hci_lmp_link_teardown(hci, handle);
@@ -1138,7 +1138,7 @@ static void bt_hci_reset(struct bt_hci_s *hci)
hci->device.inquiry_scan = 0;
hci->device.page_scan = 0;
if (hci->device.lmp_name)
- qemu_free((void *) hci->device.lmp_name);
+ g_free((void *) hci->device.lmp_name);
hci->device.lmp_name = NULL;
hci->device.class[0] = 0x00;
hci->device.class[1] = 0x00;
@@ -1816,8 +1816,8 @@ static void bt_submit_hci(struct HCIInfo *info,
LENGTH_CHECK(change_local_name);
if (hci->device.lmp_name)
- qemu_free((void *) hci->device.lmp_name);
- hci->device.lmp_name = qemu_strndup(PARAM(change_local_name, name),
+ g_free((void *) hci->device.lmp_name);
+ hci->device.lmp_name = g_strndup(PARAM(change_local_name, name),
sizeof(PARAM(change_local_name, name)));
bt_hci_event_complete_status(hci, HCI_SUCCESS);
break;
@@ -2143,7 +2143,7 @@ static void bt_hci_destroy(struct bt_device_s *dev)
struct HCIInfo *bt_new_hci(struct bt_scatternet_s *net)
{
- struct bt_hci_s *s = qemu_mallocz(sizeof(struct bt_hci_s));
+ struct bt_hci_s *s = g_malloc0(sizeof(struct bt_hci_s));
s->lm.inquiry_done = qemu_new_timer_ns(vm_clock, bt_hci_inquiry_done, s);
s->lm.inquiry_next = qemu_new_timer_ns(vm_clock, bt_hci_inquiry_next, s);
@@ -2188,7 +2188,7 @@ static void bt_hci_done(struct HCIInfo *info)
bt_device_done(&hci->device);
if (hci->device.lmp_name)
- qemu_free((void *) hci->device.lmp_name);
+ g_free((void *) hci->device.lmp_name);
/* Be gentle and send DISCONNECT to all connected peers and those
* currently waiting for us to accept or reject a connection request.
@@ -2217,5 +2217,5 @@ static void bt_hci_done(struct HCIInfo *info)
qemu_free_timer(hci->lm.inquiry_next);
qemu_free_timer(hci->conn_accept_timer);
- qemu_free(hci);
+ g_free(hci);
}
diff --git a/hw/bt-hid.c b/hw/bt-hid.c
index 5f1afe3e8..8d7a3dae2 100644
--- a/hw/bt-hid.c
+++ b/hw/bt-hid.c
@@ -504,7 +504,7 @@ static void bt_hid_destroy(struct bt_device_s *dev)
hid_free(&hid->hid);
- qemu_free(hid);
+ g_free(hid);
}
enum peripheral_minor_class {
@@ -517,7 +517,7 @@ enum peripheral_minor_class {
static struct bt_device_s *bt_hid_init(struct bt_scatternet_s *net,
enum peripheral_minor_class minor)
{
- struct bt_hid_device_s *s = qemu_mallocz(sizeof(*s));
+ struct bt_hid_device_s *s = g_malloc0(sizeof(*s));
uint32_t class =
/* Format type */
(0 << 0) |
diff --git a/hw/bt-l2cap.c b/hw/bt-l2cap.c
index 7e2f668e5..2ccba6071 100644
--- a/hw/bt-l2cap.c
+++ b/hw/bt-l2cap.c
@@ -410,7 +410,7 @@ static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap,
if (psm_info) {
/* Device supports this use-case. */
- ch = qemu_mallocz(sizeof(*ch));
+ ch = g_malloc0(sizeof(*ch));
ch->params.sdu_out = l2cap_bframe_out;
ch->params.sdu_submit = l2cap_bframe_submit;
ch->frame_in = l2cap_bframe_in;
@@ -428,7 +428,7 @@ static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap,
result = L2CAP_CR_SUCCESS;
status = L2CAP_CS_NO_INFO;
} else {
- qemu_free(ch);
+ g_free(ch);
result = L2CAP_CR_NO_MEM;
status = L2CAP_CS_NO_INFO;
@@ -473,7 +473,7 @@ static void l2cap_channel_close(struct l2cap_instance_s *l2cap,
l2cap->cid[cid] = NULL;
ch->params.close(ch->params.opaque);
- qemu_free(ch);
+ g_free(ch);
}
l2cap_disconnection_response(l2cap, cid, source_cid);
@@ -1218,13 +1218,13 @@ static void l2cap_teardown(struct l2cap_instance_s *l2cap, int send_disconnect)
for (cid = L2CAP_CID_ALLOC; cid < L2CAP_CID_MAX; cid ++)
if (l2cap->cid[cid]) {
l2cap->cid[cid]->params.close(l2cap->cid[cid]->params.opaque);
- qemu_free(l2cap->cid[cid]);
+ g_free(l2cap->cid[cid]);
}
if (l2cap->role)
- qemu_free(l2cap);
+ g_free(l2cap);
else
- qemu_free(l2cap->link);
+ g_free(l2cap->link);
}
/* L2CAP glue to lower layers in bluetooth stack (LMP) */
@@ -1236,7 +1236,7 @@ static void l2cap_lmp_connection_request(struct bt_link_s *link)
/* Always accept - we only get called if (dev->device->page_scan). */
- l2cap = qemu_mallocz(sizeof(struct slave_l2cap_instance_s));
+ l2cap = g_malloc0(sizeof(struct slave_l2cap_instance_s));
l2cap->link.slave = &dev->device;
l2cap->link.host = link->host;
l2cap_init(&l2cap->l2cap, &l2cap->link, 0);
@@ -1257,7 +1257,7 @@ static void l2cap_lmp_connection_complete(struct bt_link_s *link)
return;
}
- l2cap = qemu_mallocz(sizeof(struct l2cap_instance_s));
+ l2cap = g_malloc0(sizeof(struct l2cap_instance_s));
l2cap_init(l2cap, link, 1);
link->acl_mode = acl_active;
@@ -1353,7 +1353,7 @@ void bt_l2cap_psm_register(struct bt_l2cap_device_s *dev, int psm, int min_mtu,
exit(-1);
}
- new_psm = qemu_mallocz(sizeof(*new_psm));
+ new_psm = g_malloc0(sizeof(*new_psm));
new_psm->psm = psm;
new_psm->min_mtu = min_mtu;
new_psm->new_channel = new_channel;
diff --git a/hw/bt-sdp.c b/hw/bt-sdp.c
index cdf2d95d5..3e390ab5b 100644
--- a/hw/bt-sdp.c
+++ b/hw/bt-sdp.c
@@ -567,12 +567,12 @@ static void bt_l2cap_sdp_close_ch(void *opaque)
int i;
for (i = 0; i < sdp->services; i ++) {
- qemu_free(sdp->service_list[i].attribute_list->pair);
- qemu_free(sdp->service_list[i].attribute_list);
- qemu_free(sdp->service_list[i].uuid);
+ g_free(sdp->service_list[i].attribute_list->pair);
+ g_free(sdp->service_list[i].attribute_list);
+ g_free(sdp->service_list[i].uuid);
}
- qemu_free(sdp->service_list);
- qemu_free(sdp);
+ g_free(sdp->service_list);
+ g_free(sdp);
}
struct sdp_def_service_s {
@@ -709,10 +709,10 @@ static void sdp_service_record_build(struct sdp_service_record_s *record,
}
record->uuids = 1 << ffs(record->uuids - 1);
record->attribute_list =
- qemu_mallocz(record->attributes * sizeof(*record->attribute_list));
+ g_malloc0(record->attributes * sizeof(*record->attribute_list));
record->uuid =
- qemu_mallocz(record->uuids * sizeof(*record->uuid));
- data = qemu_malloc(len);
+ g_malloc0(record->uuids * sizeof(*record->uuid));
+ data = g_malloc(len);
record->attributes = 0;
uuid = record->uuid;
@@ -753,7 +753,7 @@ static void sdp_service_db_build(struct bt_l2cap_sdp_state_s *sdp,
while (service[sdp->services])
sdp->services ++;
sdp->service_list =
- qemu_mallocz(sdp->services * sizeof(*sdp->service_list));
+ g_malloc0(sdp->services * sizeof(*sdp->service_list));
sdp->services = 0;
while (*service) {
@@ -942,7 +942,7 @@ SERVICE(pnp,
static int bt_l2cap_sdp_new_ch(struct bt_l2cap_device_s *dev,
struct bt_l2cap_conn_params_s *params)
{
- struct bt_l2cap_sdp_state_s *sdp = qemu_mallocz(sizeof(*sdp));
+ struct bt_l2cap_sdp_state_s *sdp = g_malloc0(sizeof(*sdp));
struct sdp_def_service_s *services[] = {
&sdp_service_sdp_s,
&sdp_service_hid_s,
diff --git a/hw/bt.c b/hw/bt.c
index 34bf00457..dc99fc28f 100644
--- a/hw/bt.c
+++ b/hw/bt.c
@@ -54,7 +54,7 @@ static void bt_dummy_lmp_acl_resp(struct bt_link_s *link,
/* Slaves that don't hold any additional per link state can use these */
static void bt_dummy_lmp_connection_request(struct bt_link_s *req)
{
- struct bt_link_s *link = qemu_mallocz(sizeof(struct bt_link_s));
+ struct bt_link_s *link = g_malloc0(sizeof(struct bt_link_s));
link->slave = req->slave;
link->host = req->host;
@@ -65,13 +65,13 @@ static void bt_dummy_lmp_connection_request(struct bt_link_s *req)
static void bt_dummy_lmp_disconnect_slave(struct bt_link_s *link)
{
- qemu_free(link);
+ g_free(link);
}
static void bt_dummy_destroy(struct bt_device_s *device)
{
bt_device_done(device);
- qemu_free(device);
+ g_free(device);
}
static int bt_dev_idx = 0;
diff --git a/hw/cbus.c b/hw/cbus.c
index 8ae24e01d..7216899a0 100644
--- a/hw/cbus.c
+++ b/hw/cbus.c
@@ -132,7 +132,7 @@ static void cbus_sel(void *opaque, int line, int level)
CBus *cbus_init(qemu_irq dat)
{
- CBusPriv *s = (CBusPriv *) qemu_mallocz(sizeof(*s));
+ CBusPriv *s = (CBusPriv *) g_malloc0(sizeof(*s));
s->dat_out = dat;
s->cbus.clk = qemu_allocate_irqs(cbus_clk, s, 1)[0];
@@ -387,7 +387,7 @@ static void retu_io(void *opaque, int rw, int reg, uint16_t *val)
void *retu_init(qemu_irq irq, int vilma)
{
- CBusRetu *s = (CBusRetu *) qemu_mallocz(sizeof(*s));
+ CBusRetu *s = (CBusRetu *) g_malloc0(sizeof(*s));
s->irq = irq;
s->irqen = 0xffff;
@@ -603,7 +603,7 @@ static void tahvo_io(void *opaque, int rw, int reg, uint16_t *val)
void *tahvo_init(qemu_irq irq, int betty)
{
- CBusTahvo *s = (CBusTahvo *) qemu_mallocz(sizeof(*s));
+ CBusTahvo *s = (CBusTahvo *) g_malloc0(sizeof(*s));
s->irq = irq;
s->irqen = 0xffff;
diff --git a/hw/ccid-card-emulated.c b/hw/ccid-card-emulated.c
index 4762e8511..092301b54 100644
--- a/hw/ccid-card-emulated.c
+++ b/hw/ccid-card-emulated.c
@@ -135,7 +135,7 @@ static void emulated_apdu_from_guest(CCIDCardState *base,
const uint8_t *apdu, uint32_t len)
{
EmulatedState *card = DO_UPCAST(EmulatedState, base, base);
- EmulEvent *event = (EmulEvent *)qemu_malloc(sizeof(EmulEvent) + len);
+ EmulEvent *event = (EmulEvent *)g_malloc(sizeof(EmulEvent) + len);
assert(event);
event->p.data.type = EMUL_GUEST_APDU;
@@ -169,7 +169,7 @@ static void emulated_push_event(EmulatedState *card, EmulEvent *event)
static void emulated_push_type(EmulatedState *card, uint32_t type)
{
- EmulEvent *event = (EmulEvent *)qemu_malloc(sizeof(EmulEvent));
+ EmulEvent *event = (EmulEvent *)g_malloc(sizeof(EmulEvent));
assert(event);
event->p.gen.type = type;
@@ -178,7 +178,7 @@ static void emulated_push_type(EmulatedState *card, uint32_t type)
static void emulated_push_error(EmulatedState *card, uint64_t code)
{
- EmulEvent *event = (EmulEvent *)qemu_malloc(sizeof(EmulEvent));
+ EmulEvent *event = (EmulEvent *)g_malloc(sizeof(EmulEvent));
assert(event);
event->p.error.type = EMUL_ERROR;
@@ -189,7 +189,7 @@ static void emulated_push_error(EmulatedState *card, uint64_t code)
static void emulated_push_data_type(EmulatedState *card, uint32_t type,
const uint8_t *data, uint32_t len)
{
- EmulEvent *event = (EmulEvent *)qemu_malloc(sizeof(EmulEvent) + len);
+ EmulEvent *event = (EmulEvent *)g_malloc(sizeof(EmulEvent) + len);
assert(event);
event->p.data.type = type;
@@ -249,12 +249,12 @@ static void *handle_apdu_thread(void* arg)
QSIMPLEQ_REMOVE_HEAD(&card->guest_apdu_list, entry);
if (event->p.data.type != EMUL_GUEST_APDU) {
DPRINTF(card, 1, "unexpected message in handle_apdu_thread\n");
- qemu_free(event);
+ g_free(event);
continue;
}
if (card->reader == NULL) {
DPRINTF(card, 1, "reader is NULL\n");
- qemu_free(event);
+ g_free(event);
continue;
}
recv_len = sizeof(recv_data);
@@ -267,7 +267,7 @@ static void *handle_apdu_thread(void* arg)
} else {
emulated_push_error(card, reader_status);
}
- qemu_free(event);
+ g_free(event);
}
qemu_mutex_unlock(&card->vreader_mutex);
}
@@ -401,7 +401,7 @@ static void pipe_read(void *opaque)
DPRINTF(card, 2, "unexpected event\n");
break;
}
- qemu_free(event);
+ g_free(event);
}
QSIMPLEQ_INIT(&card->event_list);
qemu_mutex_unlock(&card->event_list_mutex);
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index b48930994..0f911127c 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -174,8 +174,6 @@
#define CIRRUS_PNPMMIO_SIZE 0x1000
-#define ABS(a) ((signed)(a) > 0 ? a : -a)
-
#define BLTUNSAFE(s) \
( \
( /* check dst is within bounds */ \
@@ -2372,7 +2370,7 @@ static void unmap_bank(CirrusVGAState *s, unsigned bank)
memory_region_del_subregion(&s->low_mem_container,
s->cirrus_bank[bank]);
memory_region_destroy(s->cirrus_bank[bank]);
- qemu_free(s->cirrus_bank[bank]);
+ g_free(s->cirrus_bank[bank]);
s->cirrus_bank[bank] = NULL;
}
}
@@ -2387,7 +2385,7 @@ static void map_linear_vram_bank(CirrusVGAState *s, unsigned bank)
&& !((s->vga.gr[0x0B] & 0x14) == 0x14)
&& !(s->vga.gr[0x0B] & 0x02)) {
- mr = qemu_malloc(sizeof(*mr));
+ mr = g_malloc(sizeof(*mr));
memory_region_init_alias(mr, names[bank], &s->vga.vram,
s->cirrus_bank_base[bank], 0x8000);
memory_region_add_subregion_overlap(
@@ -2903,7 +2901,7 @@ void isa_cirrus_vga_init(void)
{
CirrusVGAState *s;
- s = qemu_mallocz(sizeof(CirrusVGAState));
+ s = g_malloc0(sizeof(CirrusVGAState));
vga_common_init(&s->vga, VGA_RAM_SIZE);
cirrus_init_common(s, CIRRUS_ID_CLGD5430, 0);
diff --git a/hw/dp8393x.c b/hw/dp8393x.c
index 1bcd8eeba..f66844b10 100644
--- a/hw/dp8393x.c
+++ b/hw/dp8393x.c
@@ -870,7 +870,7 @@ static void nic_cleanup(VLANClientState *nc)
qemu_del_timer(s->watchdog);
qemu_free_timer(s->watchdog);
- qemu_free(s);
+ g_free(s);
}
static NetClientInfo net_dp83932_info = {
@@ -889,7 +889,7 @@ void dp83932_init(NICInfo *nd, target_phys_addr_t base, int it_shift,
qemu_check_nic_model(nd, "dp83932");
- s = qemu_mallocz(sizeof(dp8393xState));
+ s = g_malloc0(sizeof(dp8393xState));
s->mem_opaque = mem_opaque;
s->memory_rw = memory_rw;
diff --git a/hw/ds1225y.c b/hw/ds1225y.c
index 662d7b516..9875c445f 100644
--- a/hw/ds1225y.c
+++ b/hw/ds1225y.c
@@ -146,7 +146,7 @@ static int nvram_sysbus_initfn(SysBusDevice *dev)
QEMUFile *file;
int s_io;
- s->contents = qemu_mallocz(s->chip_size);
+ s->contents = g_malloc0(s->chip_size);
s_io = cpu_register_io_memory(nvram_read, nvram_write, s,
DEVICE_NATIVE_ENDIAN);
diff --git a/hw/eepro100.c b/hw/eepro100.c
index a636d309b..4e3c52f50 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -1901,7 +1901,7 @@ static int e100_nic_init(PCIDevice *pci_dev)
qemu_register_reset(nic_reset, s);
- s->vmstate = qemu_malloc(sizeof(vmstate_eepro100));
+ s->vmstate = g_malloc(sizeof(vmstate_eepro100));
memcpy(s->vmstate, &vmstate_eepro100, sizeof(vmstate_eepro100));
s->vmstate->name = s->nic->nc.model;
vmstate_register(&pci_dev->qdev, -1, s->vmstate, s);
diff --git a/hw/eeprom93xx.c b/hw/eeprom93xx.c
index 7b21f98e2..4c7158d1a 100644
--- a/hw/eeprom93xx.c
+++ b/hw/eeprom93xx.c
@@ -310,7 +310,7 @@ eeprom_t *eeprom93xx_new(DeviceState *dev, uint16_t nwords)
addrbits = 6;
}
- eeprom = (eeprom_t *)qemu_mallocz(sizeof(*eeprom) + nwords * 2);
+ eeprom = (eeprom_t *)g_malloc0(sizeof(*eeprom) + nwords * 2);
eeprom->size = nwords;
eeprom->addrbits = addrbits;
/* Output DO is tristate, read results in 1. */
@@ -325,7 +325,7 @@ void eeprom93xx_free(DeviceState *dev, eeprom_t *eeprom)
/* Destroy EEPROM. */
logout("eeprom = 0x%p\n", eeprom);
vmstate_unregister(dev, &vmstate_eeprom, eeprom);
- qemu_free(eeprom);
+ g_free(eeprom);
}
uint16_t *eeprom93xx_data(eeprom_t *eeprom)
diff --git a/hw/elf_ops.h b/hw/elf_ops.h
index 0bd72350b..6af357fc1 100644
--- a/hw/elf_ops.h
+++ b/hw/elf_ops.h
@@ -150,7 +150,7 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
i++;
}
if (nsyms) {
- syms = qemu_realloc(syms, nsyms * sizeof(*syms));
+ syms = g_realloc(syms, nsyms * sizeof(*syms));
qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
for (i = 0; i < nsyms - 1; i++) {
@@ -159,7 +159,7 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
}
}
} else {
- qemu_free(syms);
+ g_free(syms);
syms = NULL;
}
@@ -173,19 +173,19 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
goto fail;
/* Commit */
- s = qemu_mallocz(sizeof(*s));
+ s = g_malloc0(sizeof(*s));
s->lookup_symbol = glue(lookup_symbol, SZ);
glue(s->disas_symtab.elf, SZ) = syms;
s->disas_num_syms = nsyms;
s->disas_strtab = str;
s->next = syminfos;
syminfos = s;
- qemu_free(shdr_table);
+ g_free(shdr_table);
return 0;
fail:
- qemu_free(syms);
- qemu_free(str);
- qemu_free(shdr_table);
+ g_free(syms);
+ g_free(str);
+ g_free(shdr_table);
return -1;
}
@@ -238,7 +238,7 @@ static int glue(load_elf, SZ)(const char *name, int fd,
size = ehdr.e_phnum * sizeof(phdr[0]);
lseek(fd, ehdr.e_phoff, SEEK_SET);
- phdr = qemu_mallocz(size);
+ phdr = g_malloc0(size);
if (!phdr)
goto fail;
if (read(fd, phdr, size) != size)
@@ -256,7 +256,7 @@ static int glue(load_elf, SZ)(const char *name, int fd,
if (ph->p_type == PT_LOAD) {
mem_size = ph->p_memsz;
/* XXX: avoid allocating */
- data = qemu_mallocz(mem_size);
+ data = g_malloc0(mem_size);
if (ph->p_filesz > 0) {
if (lseek(fd, ph->p_offset, SEEK_SET) < 0)
goto fail;
@@ -280,18 +280,18 @@ static int glue(load_elf, SZ)(const char *name, int fd,
if ((addr + mem_size) > high)
high = addr + mem_size;
- qemu_free(data);
+ g_free(data);
data = NULL;
}
}
- qemu_free(phdr);
+ g_free(phdr);
if (lowaddr)
*lowaddr = (uint64_t)(elf_sword)low;
if (highaddr)
*highaddr = (uint64_t)(elf_sword)high;
return total_size;
fail:
- qemu_free(data);
- qemu_free(phdr);
+ g_free(data);
+ g_free(phdr);
return -1;
}
diff --git a/hw/etraxfs_dma.c b/hw/etraxfs_dma.c
index c205ec1b8..e8ad9e6a0 100644
--- a/hw/etraxfs_dma.c
+++ b/hw/etraxfs_dma.c
@@ -743,12 +743,12 @@ void *etraxfs_dmac_init(target_phys_addr_t base, int nr_channels)
{
struct fs_dma_ctrl *ctrl = NULL;
- ctrl = qemu_mallocz(sizeof *ctrl);
+ ctrl = g_malloc0(sizeof *ctrl);
ctrl->bh = qemu_bh_new(DMA_run, ctrl);
ctrl->nr_channels = nr_channels;
- ctrl->channels = qemu_mallocz(sizeof ctrl->channels[0] * nr_channels);
+ ctrl->channels = g_malloc0(sizeof ctrl->channels[0] * nr_channels);
ctrl->map = cpu_register_io_memory(dma_read, dma_write, ctrl, DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(base, nr_channels * 0x2000, ctrl->map);
diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c
index 92d4ecac8..48de6dcd4 100644
--- a/hw/etraxfs_eth.c
+++ b/hw/etraxfs_eth.c
@@ -574,7 +574,7 @@ static void eth_cleanup(VLANClientState *nc)
eth->dma_out->client.opaque = NULL;
eth->dma_in->client.opaque = NULL;
eth->dma_in->client.pull = NULL;
- qemu_free(eth);
+ g_free(eth);
}
static NetClientInfo net_etraxfs_info = {
diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
index e4847b7f9..663ad8011 100644
--- a/hw/fw_cfg.c
+++ b/hw/fw_cfg.c
@@ -177,14 +177,14 @@ static void fw_cfg_bootsplash(FWCfgState *s)
/* probing the file */
fp = probe_splashfile(filename, &file_size, &file_type);
if (fp == NULL) {
- qemu_free(filename);
+ g_free(filename);
return;
}
/* loading file data */
if (boot_splash_filedata != NULL) {
- qemu_free(boot_splash_filedata);
+ g_free(boot_splash_filedata);
}
- boot_splash_filedata = qemu_malloc(file_size);
+ boot_splash_filedata = g_malloc(file_size);
boot_splash_filedata_size = file_size;
fseek(fp, 0L, SEEK_SET);
fop_ret = fread(boot_splash_filedata, 1, file_size, fp);
@@ -203,7 +203,7 @@ static void fw_cfg_bootsplash(FWCfgState *s)
fw_cfg_add_file(s, "bootsplash.bmp",
boot_splash_filedata, boot_splash_filedata_size);
}
- qemu_free(filename);
+ g_free(filename);
}
}
@@ -385,7 +385,7 @@ int fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value)
{
uint16_t *copy;
- copy = qemu_malloc(sizeof(value));
+ copy = g_malloc(sizeof(value));
*copy = cpu_to_le16(value);
return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
@@ -394,7 +394,7 @@ int fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value)
{
uint32_t *copy;
- copy = qemu_malloc(sizeof(value));
+ copy = g_malloc(sizeof(value));
*copy = cpu_to_le32(value);
return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
@@ -403,7 +403,7 @@ int fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value)
{
uint64_t *copy;
- copy = qemu_malloc(sizeof(value));
+ copy = g_malloc(sizeof(value));
*copy = cpu_to_le64(value);
return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
@@ -436,7 +436,7 @@ int fw_cfg_add_file(FWCfgState *s, const char *filename, uint8_t *data,
if (!s->files) {
int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS;
- s->files = qemu_mallocz(dsize);
+ s->files = g_malloc0(dsize);
fw_cfg_add_bytes(s, FW_CFG_FILE_DIR, (uint8_t*)s->files, dsize);
}
diff --git a/hw/g364fb.c b/hw/g364fb.c
index a41e98879..b3020c5a6 100644
--- a/hw/g364fb.c
+++ b/hw/g364fb.c
@@ -590,7 +590,7 @@ int g364fb_mm_init(target_phys_addr_t vram_base,
G364State *s;
int io_ctrl;
- s = qemu_mallocz(sizeof(G364State));
+ s = g_malloc0(sizeof(G364State));
s->vram_size = 8 * 1024 * 1024;
s->vram_offset = qemu_ram_alloc(NULL, "g364fb.vram", s->vram_size);
diff --git a/hw/grlib_gptimer.c b/hw/grlib_gptimer.c
index 99e90336b..85869b95e 100644
--- a/hw/grlib_gptimer.c
+++ b/hw/grlib_gptimer.c
@@ -345,7 +345,7 @@ static int grlib_gptimer_init(SysBusDevice *dev)
assert(unit->nr_timers > 0);
assert(unit->nr_timers <= GPTIMER_MAX_TIMERS);
- unit->timers = qemu_mallocz(sizeof unit->timers[0] * unit->nr_timers);
+ unit->timers = g_malloc0(sizeof unit->timers[0] * unit->nr_timers);
for (i = 0; i < unit->nr_timers; i++) {
GPTimer *timer = &unit->timers[i];
diff --git a/hw/grlib_irqmp.c b/hw/grlib_irqmp.c
index b8738fc04..9490a7830 100644
--- a/hw/grlib_irqmp.c
+++ b/hw/grlib_irqmp.c
@@ -345,7 +345,7 @@ static int grlib_irqmp_init(SysBusDevice *dev)
grlib_irqmp_write,
irqmp, DEVICE_NATIVE_ENDIAN);
- irqmp->state = qemu_mallocz(sizeof *irqmp->state);
+ irqmp->state = g_malloc0(sizeof *irqmp->state);
if (irqmp_regs < 0) {
return -1;
diff --git a/hw/gus.c b/hw/gus.c
index ff9e7c7e3..37e543aa2 100644
--- a/hw/gus.c
+++ b/hw/gus.c
@@ -260,7 +260,7 @@ static int gus_initfn (ISADevice *dev)
s->shift = 2;
s->samples = AUD_get_buffer_size_out (s->voice) >> s->shift;
- s->mixbuf = qemu_mallocz (s->samples << s->shift);
+ s->mixbuf = g_malloc0 (s->samples << s->shift);
register_ioport_write (s->port, 1, 1, gus_writeb, s);
register_ioport_write (s->port, 1, 2, gus_writew, s);
diff --git a/hw/heathrow_pic.c b/hw/heathrow_pic.c
index 3ba0b0e0f..51996ab79 100644
--- a/hw/heathrow_pic.c
+++ b/hw/heathrow_pic.c
@@ -202,7 +202,7 @@ qemu_irq *heathrow_pic_init(MemoryRegion **pmem,
{
HeathrowPICS *s;
- s = qemu_mallocz(sizeof(HeathrowPICS));
+ s = g_malloc0(sizeof(HeathrowPICS));
/* only 1 CPU */
s->irqs = irqs[0];
memory_region_init_io(&s->mem, &heathrow_pic_ops, s,
diff --git a/hw/i8259.c b/hw/i8259.c
index 84d330dfa..c0b96ab5d 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -526,7 +526,7 @@ qemu_irq *i8259_init(qemu_irq parent_irq)
{
PicState2 *s;
- s = qemu_mallocz(sizeof(PicState2));
+ s = g_malloc0(sizeof(PicState2));
pic_init1(0x20, 0x4d0, &s->pics[0]);
pic_init1(0xa0, 0x4d1, &s->pics[1]);
s->pics[0].elcr_mask = 0xf8;
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index e207ca089..29521babf 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1123,7 +1123,7 @@ void ahci_init(AHCIState *s, DeviceState *qdev, int ports)
int i;
s->ports = ports;
- s->dev = qemu_mallocz(sizeof(AHCIDevice) * ports);
+ s->dev = g_malloc0(sizeof(AHCIDevice) * ports);
ahci_reg_init(s);
/* XXX BAR size should be 1k, but that breaks, so bump it to 4k for now */
memory_region_init_io(&s->mem, &ahci_mem_ops, s, "ahci", 0x1000);
@@ -1146,7 +1146,7 @@ void ahci_init(AHCIState *s, DeviceState *qdev, int ports)
void ahci_uninit(AHCIState *s)
{
memory_region_destroy(&s->mem);
- qemu_free(s->dev);
+ g_free(s->dev);
}
void ahci_reset(void *opaque)
diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index 7ee35e9bd..44fb3fef6 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -325,7 +325,7 @@ MemoryRegion *pmac_ide_init (DriveInfo **hd_table, qemu_irq irq,
{
MACIOIDEState *d;
- d = qemu_mallocz(sizeof(MACIOIDEState));
+ d = g_malloc0(sizeof(MACIOIDEState));
ide_init2_with_non_qdev_drives(&d->bus, hd_table[0], hd_table[1], irq);
if (dbdma)
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
index 9fbbf0e78..91c0e3c89 100644
--- a/hw/ide/microdrive.c
+++ b/hw/ide/microdrive.c
@@ -531,7 +531,7 @@ static int dscm1xxxx_detach(void *opaque)
PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv)
{
- MicroDriveState *md = (MicroDriveState *) qemu_mallocz(sizeof(MicroDriveState));
+ MicroDriveState *md = (MicroDriveState *) g_malloc0(sizeof(MicroDriveState));
md->card.state = md;
md->card.attach = dscm1xxxx_attach;
md->card.detach = dscm1xxxx_detach;
@@ -542,7 +542,7 @@ PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv)
qemu_allocate_irqs(md_set_irq, md, 1)[0]);
md->bus.ifs[0].drive_kind = IDE_CFATA;
md->bus.ifs[0].mdata_size = METADATA_SIZE;
- md->bus.ifs[0].mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE);
+ md->bus.ifs[0].mdata_storage = (uint8_t *) g_malloc0(METADATA_SIZE);
vmstate_register(NULL, -1, &vmstate_microdrive, md);
diff --git a/hw/ide/mmio.c b/hw/ide/mmio.c
index 10f6f4063..132b7517b 100644
--- a/hw/ide/mmio.c
+++ b/hw/ide/mmio.c
@@ -121,7 +121,7 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2,
qemu_irq irq, int shift,
DriveInfo *hd0, DriveInfo *hd1)
{
- MMIOState *s = qemu_mallocz(sizeof(MMIOState));
+ MMIOState *s = g_malloc0(sizeof(MMIOState));
int mem1, mem2;
ide_init2_with_non_qdev_drives(&s->bus, hd0, hd1, irq);
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 6bd8d2027..42071277b 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -148,10 +148,10 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
}
if (!dev->version) {
- dev->version = qemu_strdup(s->version);
+ dev->version = g_strdup(s->version);
}
if (!dev->serial) {
- dev->serial = qemu_strdup(s->drive_serial_str);
+ dev->serial = g_strdup(s->drive_serial_str);
}
add_boot_device_path(dev->conf.bootindex, &dev->qdev,
diff --git a/hw/intel-hda.c b/hw/intel-hda.c
index fa56a9221..4272204e0 100644
--- a/hw/intel-hda.c
+++ b/hw/intel-hda.c
@@ -467,8 +467,8 @@ static void intel_hda_parse_bdl(IntelHDAState *d, IntelHDAStream *st)
addr = intel_hda_addr(st->bdlp_lbase, st->bdlp_ubase);
st->bentries = st->lvi +1;
- qemu_free(st->bpl);
- st->bpl = qemu_malloc(sizeof(bpl) * st->bentries);
+ g_free(st->bpl);
+ st->bpl = g_malloc(sizeof(bpl) * st->bentries);
for (i = 0; i < st->bentries; i++, addr += 16) {
cpu_physical_memory_read(addr, buf, 16);
st->bpl[i].addr = le64_to_cpu(*(uint64_t *)buf);
diff --git a/hw/irq.c b/hw/irq.c
index 4035a8cbf..60eabe890 100644
--- a/hw/irq.c
+++ b/hw/irq.c
@@ -44,8 +44,8 @@ qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n)
struct IRQState *p;
int i;
- s = (qemu_irq *)qemu_mallocz(sizeof(qemu_irq) * n);
- p = (struct IRQState *)qemu_mallocz(sizeof(struct IRQState) * n);
+ s = (qemu_irq *)g_malloc0(sizeof(qemu_irq) * n);
+ p = (struct IRQState *)g_malloc0(sizeof(struct IRQState) * n);
for (i = 0; i < n; i++) {
p->handler = handler;
p->opaque = opaque;
@@ -58,8 +58,8 @@ qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n)
void qemu_free_irqs(qemu_irq *s)
{
- qemu_free(s[0]);
- qemu_free(s);
+ g_free(s[0]);
+ g_free(s);
}
static void qemu_notirq(void *opaque, int line, int level)
@@ -85,7 +85,7 @@ static void qemu_splitirq(void *opaque, int line, int level)
qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2)
{
- qemu_irq *s = qemu_mallocz(2 * sizeof(qemu_irq));
+ qemu_irq *s = g_malloc0(2 * sizeof(qemu_irq));
s[0] = irq1;
s[1] = irq2;
return qemu_allocate_irqs(qemu_splitirq, s, 1)[0];
diff --git a/hw/isa_mmio.c b/hw/isa_mmio.c
index 3d2af1a63..fd755ab4a 100644
--- a/hw/isa_mmio.c
+++ b/hw/isa_mmio.c
@@ -74,7 +74,7 @@ void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size)
void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size)
{
- MemoryRegion *mr = qemu_malloc(sizeof(*mr));
+ MemoryRegion *mr = g_malloc(sizeof(*mr));
isa_mmio_setup(mr, size);
memory_region_add_subregion(get_system_memory(), base, mr);
diff --git a/hw/ivshmem.c b/hw/ivshmem.c
index 42a587703..f4ae0d2b9 100644
--- a/hw/ivshmem.c
+++ b/hw/ivshmem.c
@@ -351,7 +351,7 @@ static void close_guest_eventfds(IVShmemState *s, int posn)
close(s->peers[posn].eventfds[i]);
}
- qemu_free(s->peers[posn].eventfds);
+ g_free(s->peers[posn].eventfds);
s->peers[posn].nb_eventfds = 0;
}
@@ -383,7 +383,7 @@ static void increase_dynamic_storage(IVShmemState *s, int new_min_size) {
s->nb_peers = s->nb_peers * 2;
IVSHMEM_DPRINTF("bumping storage to %d guests\n", s->nb_peers);
- s->peers = qemu_realloc(s->peers, s->nb_peers * sizeof(Peer));
+ s->peers = g_realloc(s->peers, s->nb_peers * sizeof(Peer));
/* zero out new pointers */
for (j = old_nb_alloc; j < s->nb_peers; j++) {
@@ -467,7 +467,7 @@ static void ivshmem_read(void *opaque, const uint8_t * buf, int flags)
if (guest_max_eventfd == 0) {
/* one eventfd per MSI vector */
- s->peers[incoming_posn].eventfds = (int *) qemu_malloc(s->vectors *
+ s->peers[incoming_posn].eventfds = (int *) g_malloc(s->vectors *
sizeof(int));
}
@@ -557,7 +557,7 @@ static void ivshmem_setup_msi(IVShmemState * s) {
}
/* allocate Qemu char devices for receiving interrupts */
- s->eventfd_table = qemu_mallocz(s->vectors * sizeof(EventfdEntry));
+ s->eventfd_table = g_malloc0(s->vectors * sizeof(EventfdEntry));
}
static void ivshmem_save(QEMUFile* f, void *opaque)
@@ -691,12 +691,12 @@ static int pci_ivshmem_init(PCIDevice *dev)
s->vm_id = -1;
/* allocate/initialize space for interrupt handling */
- s->peers = qemu_mallocz(s->nb_peers * sizeof(Peer));
+ s->peers = g_malloc0(s->nb_peers * sizeof(Peer));
pci_register_bar(&s->dev, 2,
PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ivshmem);
- s->eventfd_chr = qemu_mallocz(s->vectors * sizeof(CharDriverState *));
+ s->eventfd_chr = g_malloc0(s->vectors * sizeof(CharDriverState *));
qemu_chr_add_handlers(s->server_chr, ivshmem_can_receive, ivshmem_read,
ivshmem_event, s);
diff --git a/hw/jazz_led.c b/hw/jazz_led.c
index 1dc22cf2e..eb472a04c 100644
--- a/hw/jazz_led.c
+++ b/hw/jazz_led.c
@@ -312,7 +312,7 @@ void jazz_led_init(target_phys_addr_t base)
LedState *s;
int io;
- s = qemu_mallocz(sizeof(LedState));
+ s = g_malloc0(sizeof(LedState));
s->state = REDRAW_SEGMENTS | REDRAW_BACKGROUND;
diff --git a/hw/leon3.c b/hw/leon3.c
index 919f49fc1..a62a9419f 100644
--- a/hw/leon3.c
+++ b/hw/leon3.c
@@ -122,7 +122,7 @@ static void leon3_generic_hw_init(ram_addr_t ram_size,
cpu_sparc_set_id(env, 0);
/* Reset data */
- reset_info = qemu_mallocz(sizeof(ResetData));
+ reset_info = g_malloc0(sizeof(ResetData));
reset_info->env = env;
qemu_register_reset(main_cpu_reset, reset_info);
diff --git a/hw/lm32_boards.c b/hw/lm32_boards.c
index 64629230c..d18aad743 100644
--- a/hw/lm32_boards.c
+++ b/hw/lm32_boards.c
@@ -95,7 +95,7 @@ static void lm32_evr_init(ram_addr_t ram_size_not_used,
int timer0_irq = 1;
int timer1_irq = 3;
- reset_info = qemu_mallocz(sizeof(ResetInfo));
+ reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";
@@ -190,7 +190,7 @@ static void lm32_uclinux_init(ram_addr_t ram_size_not_used,
target_phys_addr_t initrd_base = 0x08400000;
size_t initrd_max = 0x01000000;
- reset_info = qemu_mallocz(sizeof(ResetInfo));
+ reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";
diff --git a/hw/lm32_hwsetup.h b/hw/lm32_hwsetup.h
index 9f478217b..8fc285efc 100644
--- a/hw/lm32_hwsetup.h
+++ b/hw/lm32_hwsetup.h
@@ -57,8 +57,8 @@ static inline HWSetup *hwsetup_init(void)
{
HWSetup *hw;
- hw = qemu_malloc(sizeof(HWSetup));
- hw->data = qemu_mallocz(TARGET_PAGE_SIZE);
+ hw = g_malloc(sizeof(HWSetup));
+ hw->data = g_malloc0(TARGET_PAGE_SIZE);
hw->ptr = hw->data;
return hw;
@@ -66,8 +66,8 @@ static inline HWSetup *hwsetup_init(void)
static inline void hwsetup_free(HWSetup *hw)
{
- qemu_free(hw->data);
- qemu_free(hw);
+ g_free(hw->data);
+ g_free(hw);
}
static inline void hwsetup_create_rom(HWSetup *hw,
diff --git a/hw/loader.c b/hw/loader.c
index 35d792e64..8efb1466c 100644
--- a/hw/loader.c
+++ b/hw/loader.c
@@ -91,11 +91,11 @@ int read_targphys(const char *name,
uint8_t *buf;
size_t did;
- buf = qemu_malloc(nbytes);
+ buf = g_malloc(nbytes);
did = read(fd, buf, nbytes);
if (did > 0)
rom_add_blob_fixed("read", buf, did, dst_addr);
- qemu_free(buf);
+ g_free(buf);
return did;
}
@@ -234,9 +234,9 @@ static void *load_at(int fd, int offset, int size)
void *ptr;
if (lseek(fd, offset, SEEK_SET) < 0)
return NULL;
- ptr = qemu_malloc(size);
+ ptr = g_malloc(size);
if (read(fd, ptr, size) != size) {
- qemu_free(ptr);
+ g_free(ptr);
return NULL;
}
return ptr;
@@ -351,14 +351,14 @@ static void *zalloc(void *x, unsigned items, unsigned size)
size *= items;
size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1);
- p = qemu_malloc(size);
+ p = g_malloc(size);
return (p);
}
static void zfree(void *x, void *addr)
{
- qemu_free(addr);
+ g_free(addr);
}
@@ -476,7 +476,7 @@ int load_uimage(const char *filename, target_phys_addr_t *ep,
}
*ep = hdr->ih_ep;
- data = qemu_malloc(hdr->ih_size);
+ data = g_malloc(hdr->ih_size);
if (read(fd, data, hdr->ih_size) != hdr->ih_size) {
fprintf(stderr, "Error reading file\n");
@@ -490,10 +490,10 @@ int load_uimage(const char *filename, target_phys_addr_t *ep,
compressed_data = data;
max_bytes = UBOOT_MAX_GUNZIP_BYTES;
- data = qemu_malloc(max_bytes);
+ data = g_malloc(max_bytes);
bytes = gunzip(data, max_bytes, compressed_data, hdr->ih_size);
- qemu_free(compressed_data);
+ g_free(compressed_data);
if (bytes < 0) {
fprintf(stderr, "Unable to decompress gzipped image!\n");
goto out;
@@ -510,7 +510,7 @@ int load_uimage(const char *filename, target_phys_addr_t *ep,
out:
if (data)
- qemu_free(data);
+ g_free(data);
close(fd);
return ret;
}
@@ -564,11 +564,11 @@ int rom_add_file(const char *file, const char *fw_dir,
int rc, fd = -1;
char devpath[100];
- rom = qemu_mallocz(sizeof(*rom));
- rom->name = qemu_strdup(file);
+ rom = g_malloc0(sizeof(*rom));
+ rom->name = g_strdup(file);
rom->path = qemu_find_file(QEMU_FILE_TYPE_BIOS, rom->name);
if (rom->path == NULL) {
- rom->path = qemu_strdup(file);
+ rom->path = g_strdup(file);
}
fd = open(rom->path, O_RDONLY | O_BINARY);
@@ -579,12 +579,12 @@ int rom_add_file(const char *file, const char *fw_dir,
}
if (fw_dir) {
- rom->fw_dir = qemu_strdup(fw_dir);
- rom->fw_file = qemu_strdup(file);
+ rom->fw_dir = g_strdup(fw_dir);
+ rom->fw_file = g_strdup(file);
}
rom->addr = addr;
rom->romsize = lseek(fd, 0, SEEK_END);
- rom->data = qemu_mallocz(rom->romsize);
+ rom->data = g_malloc0(rom->romsize);
lseek(fd, 0, SEEK_SET);
rc = read(fd, rom->data, rom->romsize);
if (rc != rom->romsize) {
@@ -618,10 +618,10 @@ int rom_add_file(const char *file, const char *fw_dir,
err:
if (fd != -1)
close(fd);
- qemu_free(rom->data);
- qemu_free(rom->path);
- qemu_free(rom->name);
- qemu_free(rom);
+ g_free(rom->data);
+ g_free(rom->path);
+ g_free(rom->name);
+ g_free(rom);
return -1;
}
@@ -630,11 +630,11 @@ int rom_add_blob(const char *name, const void *blob, size_t len,
{
Rom *rom;
- rom = qemu_mallocz(sizeof(*rom));
- rom->name = qemu_strdup(name);
+ rom = g_malloc0(sizeof(*rom));
+ rom->name = g_strdup(name);
rom->addr = addr;
rom->romsize = len;
- rom->data = qemu_mallocz(rom->romsize);
+ rom->data = g_malloc0(rom->romsize);
memcpy(rom->data, blob, len);
rom_insert(rom);
return 0;
@@ -664,7 +664,7 @@ static void rom_reset(void *unused)
cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize);
if (rom->isrom) {
/* rom needs to be written only once */
- qemu_free(rom->data);
+ g_free(rom->data);
rom->data = NULL;
}
}
diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index 41c2fb0b7..1643a63ee 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -353,10 +353,10 @@ static void lsi_soft_reset(LSIState *s)
while (!QTAILQ_EMPTY(&s->queue)) {
p = QTAILQ_FIRST(&s->queue);
QTAILQ_REMOVE(&s->queue, p, next);
- qemu_free(p);
+ g_free(p);
}
if (s->current) {
- qemu_free(s->current);
+ g_free(s->current);
s->current = NULL;
}
}
@@ -664,7 +664,7 @@ static void lsi_request_cancelled(SCSIRequest *req)
if (s->current && req == s->current->req) {
scsi_req_unref(req);
- qemu_free(s->current);
+ g_free(s->current);
s->current = NULL;
return;
}
@@ -672,7 +672,7 @@ static void lsi_request_cancelled(SCSIRequest *req)
if (p) {
QTAILQ_REMOVE(&s->queue, p, next);
scsi_req_unref(req);
- qemu_free(p);
+ g_free(p);
}
}
@@ -723,7 +723,7 @@ static void lsi_command_complete(SCSIRequest *req, uint32_t status)
if (s->current && req == s->current->req) {
scsi_req_unref(s->current->req);
- qemu_free(s->current);
+ g_free(s->current);
s->current = NULL;
}
lsi_resume_script(s);
@@ -779,7 +779,7 @@ static void lsi_do_command(LSIState *s)
}
assert(s->current == NULL);
- s->current = qemu_mallocz(sizeof(lsi_request));
+ s->current = g_malloc0(sizeof(lsi_request));
s->current->tag = s->select_tag;
s->current->req = scsi_req_new(dev, s->current->tag, s->current_lun, buf,
s->current);
diff --git a/hw/m48t59.c b/hw/m48t59.c
index 537c0f7b1..401b9693e 100644
--- a/hw/m48t59.c
+++ b/hw/m48t59.c
@@ -679,7 +679,7 @@ M48t59State *m48t59_init_isa(uint32_t io_base, uint16_t size, int type)
static void m48t59_init_common(M48t59State *s)
{
- s->buffer = qemu_mallocz(s->size);
+ s->buffer = g_malloc0(s->size);
if (s->type == 59) {
s->alrm_timer = qemu_new_timer_ns(vm_clock, &alarm_cb, s);
s->wd_timer = qemu_new_timer_ns(vm_clock, &watchdog_cb, s);
diff --git a/hw/mac_dbdma.c b/hw/mac_dbdma.c
index 350d901ed..5affdd18a 100644
--- a/hw/mac_dbdma.c
+++ b/hw/mac_dbdma.c
@@ -846,7 +846,7 @@ void* DBDMA_init (MemoryRegion **dbdma_mem)
{
DBDMAState *s;
- s = qemu_mallocz(sizeof(DBDMAState));
+ s = g_malloc0(sizeof(DBDMAState));
memory_region_init_io(&s->mem, &dbdma_ops, s, "dbdma", 0x1000);
*dbdma_mem = &s->mem;
diff --git a/hw/mac_nvram.c b/hw/mac_nvram.c
index ced1e585d..ed0a2b7ef 100644
--- a/hw/mac_nvram.c
+++ b/hw/mac_nvram.c
@@ -121,8 +121,8 @@ MacIONVRAMState *macio_nvram_init (target_phys_addr_t size,
{
MacIONVRAMState *s;
- s = qemu_mallocz(sizeof(MacIONVRAMState));
- s->data = qemu_mallocz(size);
+ s = g_malloc0(sizeof(MacIONVRAMState));
+ s->data = g_malloc0(size);
s->size = size;
s->it_shift = it_shift;
diff --git a/hw/mcf5206.c b/hw/mcf5206.c
index fce282d98..15d6f22f1 100644
--- a/hw/mcf5206.c
+++ b/hw/mcf5206.c
@@ -132,7 +132,7 @@ static m5206_timer_state *m5206_timer_init(qemu_irq irq)
m5206_timer_state *s;
QEMUBH *bh;
- s = (m5206_timer_state *)qemu_mallocz(sizeof(m5206_timer_state));
+ s = (m5206_timer_state *)g_malloc0(sizeof(m5206_timer_state));
bh = qemu_bh_new(m5206_timer_trigger, s);
s->timer = ptimer_init(bh);
s->irq = irq;
@@ -523,7 +523,7 @@ qemu_irq *mcf5206_init(uint32_t base, CPUState *env)
qemu_irq *pic;
int iomemtype;
- s = (m5206_mbar_state *)qemu_mallocz(sizeof(m5206_mbar_state));
+ s = (m5206_mbar_state *)g_malloc0(sizeof(m5206_mbar_state));
iomemtype = cpu_register_io_memory(m5206_mbar_readfn,
m5206_mbar_writefn, s,
DEVICE_NATIVE_ENDIAN);
diff --git a/hw/mcf5208.c b/hw/mcf5208.c
index 78fbc5f23..8fe507f82 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -185,7 +185,7 @@ static void mcf5208_sys_init(qemu_irq *pic)
cpu_register_physical_memory(0xfc0a8000, 0x00004000, iomemtype);
/* Timers. */
for (i = 0; i < 2; i++) {
- s = (m5208_timer_state *)qemu_mallocz(sizeof(m5208_timer_state));
+ s = (m5208_timer_state *)g_malloc0(sizeof(m5208_timer_state));
bh = qemu_bh_new(m5208_timer_trigger, s);
s->timer = ptimer_init(bh);
iomemtype = cpu_register_io_memory(m5208_timer_readfn,
diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c
index 748eb5906..42a5d7795 100644
--- a/hw/mcf_fec.c
+++ b/hw/mcf_fec.c
@@ -447,7 +447,7 @@ static void mcf_fec_cleanup(VLANClientState *nc)
cpu_unregister_io_memory(s->mmio_index);
- qemu_free(s);
+ g_free(s);
}
static NetClientInfo net_mcf_fec_info = {
@@ -464,7 +464,7 @@ void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq)
qemu_check_nic_model(nd, "mcf_fec");
- s = (mcf_fec_state *)qemu_mallocz(sizeof(mcf_fec_state));
+ s = (mcf_fec_state *)g_malloc0(sizeof(mcf_fec_state));
s->irq = irq;
s->mmio_index = cpu_register_io_memory(mcf_fec_readfn,
mcf_fec_writefn, s,
diff --git a/hw/mcf_intc.c b/hw/mcf_intc.c
index 6cb0a09b7..99092e72d 100644
--- a/hw/mcf_intc.c
+++ b/hw/mcf_intc.c
@@ -144,7 +144,7 @@ qemu_irq *mcf_intc_init(target_phys_addr_t base, CPUState *env)
mcf_intc_state *s;
int iomemtype;
- s = qemu_mallocz(sizeof(mcf_intc_state));
+ s = g_malloc0(sizeof(mcf_intc_state));
s->env = env;
mcf_intc_reset(s);
diff --git a/hw/mcf_uart.c b/hw/mcf_uart.c
index 905e116de..6118ccb60 100644
--- a/hw/mcf_uart.c
+++ b/hw/mcf_uart.c
@@ -272,7 +272,7 @@ void *mcf_uart_init(qemu_irq irq, CharDriverState *chr)
{
mcf_uart_state *s;
- s = qemu_mallocz(sizeof(mcf_uart_state));
+ s = g_malloc0(sizeof(mcf_uart_state));
s->chr = chr;
s->irq = irq;
if (chr) {
diff --git a/hw/milkymist.c b/hw/milkymist.c
index 787984040..93288c840 100644
--- a/hw/milkymist.c
+++ b/hw/milkymist.c
@@ -99,7 +99,7 @@ milkymist_init(ram_addr_t ram_size_not_used,
target_phys_addr_t cmdline_base = sdram_base + 0x1000000;
size_t initrd_max = sdram_size - 0x1002000;
- reset_info = qemu_mallocz(sizeof(ResetInfo));
+ reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";
diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index 420fada25..ec8c88e2e 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -140,7 +140,7 @@ static int64_t load_kernel (CPUState *env)
/* Setup prom parameters. */
prom_size = ENVP_NB_ENTRIES * (sizeof(int32_t) + ENVP_ENTRY_SIZE);
- prom_buf = qemu_malloc(prom_size);
+ prom_buf = g_malloc(prom_size);
prom_set(prom_buf, index++, "%s", loaderparams.kernel_filename);
if (initrd_size > 0) {
@@ -313,7 +313,7 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,
if (filename) {
bios_size = load_image_targphys(filename, 0x1fc00000LL,
BIOS_SIZE);
- qemu_free(filename);
+ g_free(filename);
} else {
bios_size = -1;
}
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index f6ab6dc45..ea20510cb 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -158,7 +158,7 @@ void mips_jazz_init (ram_addr_t ram_size,
if (filename) {
bios_size = load_image_targphys(filename, 0xfff00000LL,
MAGNUM_BIOS_SIZE);
- qemu_free(filename);
+ g_free(filename);
} else {
bios_size = -1;
}
@@ -207,7 +207,7 @@ void mips_jazz_init (ram_addr_t ram_size,
for (n = 0; n < nb_nics; n++) {
nd = &nd_table[n];
if (!nd->model)
- nd->model = qemu_strdup("dp83932");
+ nd->model = g_strdup("dp83932");
if (strcmp(nd->model, "dp83932") == 0) {
dp83932_init(nd, 0x80001000, 2, rc4030[4],
rc4030_opaque, rc4030_dma_memory_rw);
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index ed2a483c9..5bdb45b74 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -433,7 +433,7 @@ static MaltaFPGAState *malta_fpga_init(target_phys_addr_t base, qemu_irq uart_ir
MaltaFPGAState *s;
int malta;
- s = (MaltaFPGAState *)qemu_mallocz(sizeof(MaltaFPGAState));
+ s = (MaltaFPGAState *)g_malloc0(sizeof(MaltaFPGAState));
malta = cpu_register_io_memory(malta_fpga_read,
malta_fpga_write, s,
@@ -709,7 +709,7 @@ static int64_t load_kernel (void)
/* Setup prom parameters. */
prom_size = ENVP_NB_ENTRIES * (sizeof(int32_t) + ENVP_ENTRY_SIZE);
- prom_buf = qemu_malloc(prom_size);
+ prom_buf = g_malloc(prom_size);
prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_filename);
if (initrd_size > 0) {
@@ -863,7 +863,7 @@ void mips_malta_init (ram_addr_t ram_size,
if (filename) {
bios_size = load_image_targphys(filename, 0x1fc00000LL,
BIOS_SIZE);
- qemu_free(filename);
+ g_free(filename);
} else {
bios_size = -1;
}
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index 380a7eb78..0d46cc4c5 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -138,7 +138,7 @@ mips_mipssim_init (ram_addr_t ram_size,
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
- reset_info = qemu_mallocz(sizeof(ResetData));
+ reset_info = g_malloc0(sizeof(ResetData));
reset_info->env = env;
reset_info->vector = env->active_tc.PC;
qemu_register_reset(main_cpu_reset, reset_info);
@@ -158,7 +158,7 @@ mips_mipssim_init (ram_addr_t ram_size,
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, 0x1fc00000LL, BIOS_SIZE);
- qemu_free(filename);
+ g_free(filename);
} else {
bios_size = -1;
}
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index 2834a46d5..9d90568e4 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -126,7 +126,7 @@ static int64_t load_kernel(void)
/* Store command line. */
params_size = 264;
- params_buf = qemu_malloc(params_size);
+ params_buf = g_malloc(params_size);
params_buf[0] = tswap32(ram_size);
params_buf[1] = tswap32(0x12345678);
@@ -186,7 +186,7 @@ void mips_r4k_init (ram_addr_t ram_size,
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
- reset_info = qemu_mallocz(sizeof(ResetData));
+ reset_info = g_malloc0(sizeof(ResetData));
reset_info->env = env;
reset_info->vector = env->active_tc.PC;
qemu_register_reset(main_cpu_reset, reset_info);
@@ -248,7 +248,7 @@ void mips_r4k_init (ram_addr_t ram_size,
bios_name);
}
if (filename) {
- qemu_free(filename);
+ g_free(filename);
}
if (kernel_filename) {
diff --git a/hw/mipsnet.c b/hw/mipsnet.c
index 0db3ba7a8..b889ee006 100644
--- a/hw/mipsnet.c
+++ b/hw/mipsnet.c
@@ -228,7 +228,7 @@ static void mipsnet_cleanup(VLANClientState *nc)
isa_unassign_ioport(s->io_base, 36);
- qemu_free(s);
+ g_free(s);
}
static NetClientInfo net_mipsnet_info = {
@@ -245,7 +245,7 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd)
qemu_check_nic_model(nd, "mipsnet");
- s = qemu_mallocz(sizeof(MIPSnetState));
+ s = g_malloc0(sizeof(MIPSnetState));
register_ioport_write(base, 36, 1, mipsnet_ioport_write, s);
register_ioport_read(base, 36, 1, mipsnet_ioport_read, s);
diff --git a/hw/msix.c b/hw/msix.c
index 8536c3fc8..b15bafc06 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -219,10 +219,10 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries,
if (nentries > MSIX_MAX_ENTRIES)
return -EINVAL;
- dev->msix_entry_used = qemu_mallocz(MSIX_MAX_ENTRIES *
+ dev->msix_entry_used = g_malloc0(MSIX_MAX_ENTRIES *
sizeof *dev->msix_entry_used);
- dev->msix_table_page = qemu_mallocz(MSIX_PAGE_SIZE);
+ dev->msix_table_page = g_malloc0(MSIX_PAGE_SIZE);
msix_mask_all(dev, nentries);
memory_region_init_io(&dev->msix_mmio, &msix_mmio_ops, dev,
@@ -240,9 +240,9 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries,
err_config:
dev->msix_entries_nr = 0;
memory_region_destroy(&dev->msix_mmio);
- qemu_free(dev->msix_table_page);
+ g_free(dev->msix_table_page);
dev->msix_table_page = NULL;
- qemu_free(dev->msix_entry_used);
+ g_free(dev->msix_entry_used);
dev->msix_entry_used = NULL;
return ret;
}
@@ -268,9 +268,9 @@ int msix_uninit(PCIDevice *dev, MemoryRegion *bar)
dev->msix_entries_nr = 0;
memory_region_del_subregion(bar, &dev->msix_mmio);
memory_region_destroy(&dev->msix_mmio);
- qemu_free(dev->msix_table_page);
+ g_free(dev->msix_table_page);
dev->msix_table_page = NULL;
- qemu_free(dev->msix_entry_used);
+ g_free(dev->msix_entry_used);
dev->msix_entry_used = NULL;
dev->cap_present &= ~QEMU_PCI_CAP_MSIX;
return 0;
diff --git a/hw/msmouse.c b/hw/msmouse.c
index 67c6cd43e..b611c2f23 100644
--- a/hw/msmouse.c
+++ b/hw/msmouse.c
@@ -61,14 +61,14 @@ static int msmouse_chr_write (struct CharDriverState *s, const uint8_t *buf, int
static void msmouse_chr_close (struct CharDriverState *chr)
{
- qemu_free (chr);
+ g_free (chr);
}
int qemu_chr_open_msmouse(QemuOpts *opts, CharDriverState **_chr)
{
CharDriverState *chr;
- chr = qemu_mallocz(sizeof(CharDriverState));
+ chr = g_malloc0(sizeof(CharDriverState));
chr->chr_write = msmouse_chr_write;
chr->chr_close = msmouse_chr_close;
diff --git a/hw/multiboot.c b/hw/multiboot.c
index a1d3f4129..b4484a326 100644
--- a/hw/multiboot.c
+++ b/hw/multiboot.c
@@ -187,7 +187,7 @@ int load_multiboot(void *fw_cfg,
mb_kernel_size = elf_high - elf_low;
mh_entry_addr = elf_entry;
- mbs.mb_buf = qemu_malloc(mb_kernel_size);
+ mbs.mb_buf = g_malloc(mb_kernel_size);
if (rom_copy(mbs.mb_buf, mh_load_addr, mb_kernel_size) != mb_kernel_size) {
fprintf(stderr, "Error while fetching elf kernel from rom\n");
exit(1);
@@ -220,7 +220,7 @@ int load_multiboot(void *fw_cfg,
mb_debug("qemu: loading multiboot kernel (%#x bytes) at %#x\n",
mb_load_size, mh_load_addr);
- mbs.mb_buf = qemu_malloc(mb_kernel_size);
+ mbs.mb_buf = g_malloc(mb_kernel_size);
fseek(f, mb_kernel_text_offset, SEEK_SET);
if (fread(mbs.mb_buf, 1, mb_load_size, f) != mb_load_size) {
fprintf(stderr, "fread() failed\n");
@@ -252,7 +252,7 @@ int load_multiboot(void *fw_cfg,
mbs.mb_buf_size = TARGET_PAGE_ALIGN(mbs.mb_buf_size);
/* enlarge mb_buf to hold cmdlines and mb-info structs */
- mbs.mb_buf = qemu_realloc(mbs.mb_buf, mbs.mb_buf_size);
+ mbs.mb_buf = g_realloc(mbs.mb_buf, mbs.mb_buf_size);
mbs.offset_cmdlines = mbs.offset_mbinfo + mbs.mb_mods_avail * MB_MOD_SIZE;
if (initrd_filename) {
@@ -281,7 +281,7 @@ int load_multiboot(void *fw_cfg,
}
mbs.mb_buf_size = TARGET_PAGE_ALIGN(mb_mod_length + mbs.mb_buf_size);
- mbs.mb_buf = qemu_realloc(mbs.mb_buf, mbs.mb_buf_size);
+ mbs.mb_buf = g_realloc(mbs.mb_buf, mbs.mb_buf_size);
load_image(initrd_filename, (unsigned char *)mbs.mb_buf + offs);
mb_add_mod(&mbs, mbs.mb_buf_phys + offs,
@@ -320,7 +320,7 @@ int load_multiboot(void *fw_cfg,
mb_debug(" mb_mods_count = %d\n", mbs.mb_mods_count);
/* save bootinfo off the stack */
- mb_bootinfo_data = qemu_malloc(sizeof(bootinfo));
+ mb_bootinfo_data = g_malloc(sizeof(bootinfo));
memcpy(mb_bootinfo_data, bootinfo, sizeof(bootinfo));
/* Pass variables to option rom */
diff --git a/hw/nand.c b/hw/nand.c
index 28d9f0b60..c27783e8a 100644
--- a/hw/nand.c
+++ b/hw/nand.c
@@ -399,7 +399,7 @@ static int nand_device_init(SysBusDevice *dev)
pagesize += 1 << s->page_shift;
}
if (pagesize) {
- s->storage = (uint8_t *) memset(qemu_malloc(s->pages * pagesize),
+ s->storage = (uint8_t *) memset(g_malloc(s->pages * pagesize),
0xff, s->pages * pagesize);
}
/* Give s->ioaddr a sane value in case we save state before it is used. */
diff --git a/hw/nseries.c b/hw/nseries.c
index 6a5575e78..144fd5a42 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -654,7 +654,7 @@ static uint32_t mipid_txrx(void *opaque, uint32_t cmd, int len)
static void *mipid_init(void)
{
- struct mipid_s *s = (struct mipid_s *) qemu_mallocz(sizeof(*s));
+ struct mipid_s *s = (struct mipid_s *) g_malloc0(sizeof(*s));
s->id = 0x838f03;
mipid_reset(s);
@@ -710,10 +710,10 @@ static void n800_dss_init(struct rfbi_chip_s *chip)
chip->write(chip->opaque, 1, 0x01); /* Input Data Format */
chip->write(chip->opaque, 1, 0x01); /* Data Source Select */
- fb_blank = memset(qemu_malloc(800 * 480 * 2), 0xff, 800 * 480 * 2);
+ fb_blank = memset(g_malloc(800 * 480 * 2), 0xff, 800 * 480 * 2);
/* Display Memory Data Port */
chip->block(chip->opaque, 1, fb_blank, 800 * 480 * 2, 800);
- qemu_free(fb_blank);
+ g_free(fb_blank);
}
static void n8x0_dss_setup(struct n800_s *s)
@@ -1270,7 +1270,7 @@ static void n8x0_init(ram_addr_t ram_size, const char *boot_device,
const char *kernel_cmdline, const char *initrd_filename,
const char *cpu_model, struct arm_boot_info *binfo, int model)
{
- struct n800_s *s = (struct n800_s *) qemu_mallocz(sizeof(*s));
+ struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s));
int sdram_size = binfo->ram_size;
DisplayState *ds;
diff --git a/hw/omap.h b/hw/omap.h
index a064353ab..2a6d58925 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -1107,7 +1107,7 @@ inline static int debug_register_io_memory(CPUReadMemoryFunc * const *mem_read,
CPUWriteMemoryFunc * const *mem_write,
void *opaque)
{
- struct io_fn *s = qemu_malloc(sizeof(struct io_fn));
+ struct io_fn *s = g_malloc(sizeof(struct io_fn));
s->mem_read = mem_read;
s->mem_write = mem_write;
diff --git a/hw/omap1.c b/hw/omap1.c
index 400de475d..614fd31b0 100644
--- a/hw/omap1.c
+++ b/hw/omap1.c
@@ -255,7 +255,7 @@ static struct omap_mpu_timer_s *omap_mpu_timer_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *)
- qemu_mallocz(sizeof(struct omap_mpu_timer_s));
+ g_malloc0(sizeof(struct omap_mpu_timer_s));
s->irq = irq;
s->clk = clk;
@@ -379,7 +379,7 @@ static struct omap_watchdog_timer_s *omap_wd_timer_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *)
- qemu_mallocz(sizeof(struct omap_watchdog_timer_s));
+ g_malloc0(sizeof(struct omap_watchdog_timer_s));
s->timer.irq = irq;
s->timer.clk = clk;
@@ -481,7 +481,7 @@ static struct omap_32khz_timer_s *omap_os_timer_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *)
- qemu_mallocz(sizeof(struct omap_32khz_timer_s));
+ g_malloc0(sizeof(struct omap_32khz_timer_s));
s->timer.irq = irq;
s->timer.clk = clk;
@@ -1188,7 +1188,7 @@ static struct omap_tipb_bridge_s *omap_tipb_bridge_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *)
- qemu_mallocz(sizeof(struct omap_tipb_bridge_s));
+ g_malloc0(sizeof(struct omap_tipb_bridge_s));
s->abort = abort_irq;
omap_tipb_bridge_reset(s);
@@ -2025,7 +2025,7 @@ struct omap_mpuio_s *omap_mpuio_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_mpuio_s *s = (struct omap_mpuio_s *)
- qemu_mallocz(sizeof(struct omap_mpuio_s));
+ g_malloc0(sizeof(struct omap_mpuio_s));
s->irq = gpio_int;
s->kbd_irq = kbd_int;
@@ -2211,7 +2211,7 @@ struct omap_uwire_s *omap_uwire_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_uwire_s *s = (struct omap_uwire_s *)
- qemu_mallocz(sizeof(struct omap_uwire_s));
+ g_malloc0(sizeof(struct omap_uwire_s));
s->txirq = irq[0];
s->rxirq = irq[1];
@@ -2819,7 +2819,7 @@ static struct omap_rtc_s *omap_rtc_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_rtc_s *s = (struct omap_rtc_s *)
- qemu_mallocz(sizeof(struct omap_rtc_s));
+ g_malloc0(sizeof(struct omap_rtc_s));
s->irq = irq[0];
s->alarm = irq[1];
@@ -3339,7 +3339,7 @@ struct omap_mcbsp_s *omap_mcbsp_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *)
- qemu_mallocz(sizeof(struct omap_mcbsp_s));
+ g_malloc0(sizeof(struct omap_mcbsp_s));
s->txirq = irq[0];
s->rxirq = irq[1];
@@ -3515,7 +3515,7 @@ static struct omap_lpg_s *omap_lpg_init(target_phys_addr_t base, omap_clk clk)
{
int iomemtype;
struct omap_lpg_s *s = (struct omap_lpg_s *)
- qemu_mallocz(sizeof(struct omap_lpg_s));
+ g_malloc0(sizeof(struct omap_lpg_s));
s->tm = qemu_new_timer_ms(rt_clock, omap_lpg_tick, s);
@@ -3711,7 +3711,7 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size,
{
int i;
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *)
- qemu_mallocz(sizeof(struct omap_mpu_state_s));
+ g_malloc0(sizeof(struct omap_mpu_state_s));
ram_addr_t imif_base, emiff_base;
qemu_irq *cpu_irq;
qemu_irq dma_irqs[6];
diff --git a/hw/omap2.c b/hw/omap2.c
index c9b35405e..3b51ac525 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -591,7 +591,7 @@ static struct omap_eac_s *omap_eac_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_eac_s *s = (struct omap_eac_s *)
- qemu_mallocz(sizeof(struct omap_eac_s));
+ g_malloc0(sizeof(struct omap_eac_s));
s->irq = irq;
s->codec.rxdrq = *drq ++;
@@ -777,7 +777,7 @@ static struct omap_sti_s *omap_sti_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_sti_s *s = (struct omap_sti_s *)
- qemu_mallocz(sizeof(struct omap_sti_s));
+ g_malloc0(sizeof(struct omap_sti_s));
s->irq = irq;
omap_sti_reset(s);
@@ -1790,7 +1790,7 @@ static struct omap_prcm_s *omap_prcm_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_prcm_s *s = (struct omap_prcm_s *)
- qemu_mallocz(sizeof(struct omap_prcm_s));
+ g_malloc0(sizeof(struct omap_prcm_s));
s->irq[0] = mpu_int;
s->irq[1] = dsp_int;
@@ -2163,7 +2163,7 @@ static struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_sysctl_s *s = (struct omap_sysctl_s *)
- qemu_mallocz(sizeof(struct omap_sysctl_s));
+ g_malloc0(sizeof(struct omap_sysctl_s));
s->mpu = mpu;
omap_sysctl_reset(s);
@@ -2228,7 +2228,7 @@ struct omap_mpu_state_s *omap2420_mpu_init(unsigned long sdram_size,
const char *core)
{
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *)
- qemu_mallocz(sizeof(struct omap_mpu_state_s));
+ g_malloc0(sizeof(struct omap_mpu_state_s));
ram_addr_t sram_base, q2_base;
qemu_irq *cpu_irq;
qemu_irq dma_irqs[4];
diff --git a/hw/omap_clk.c b/hw/omap_clk.c
index 577b326ae..844800606 100644
--- a/hw/omap_clk.c
+++ b/hw/omap_clk.c
@@ -1239,7 +1239,7 @@ void omap_clk_init(struct omap_mpu_state_s *mpu)
for (i = onchip_clks, count = 0; *i; i ++)
if ((*i)->flags & flag)
count ++;
- mpu->clks = (struct clk *) qemu_mallocz(sizeof(struct clk) * (count + 1));
+ mpu->clks = (struct clk *) g_malloc0(sizeof(struct clk) * (count + 1));
for (i = onchip_clks, j = mpu->clks; *i; i ++)
if ((*i)->flags & flag) {
memcpy(j, *i, sizeof(struct clk));
diff --git a/hw/omap_dma.c b/hw/omap_dma.c
index 8e2dcc90c..f943d4e14 100644
--- a/hw/omap_dma.c
+++ b/hw/omap_dma.c
@@ -1620,7 +1620,7 @@ struct soc_dma_s *omap_dma_init(target_phys_addr_t base, qemu_irq *irqs,
{
int iomemtype, num_irqs, memsize, i;
struct omap_dma_s *s = (struct omap_dma_s *)
- qemu_mallocz(sizeof(struct omap_dma_s));
+ g_malloc0(sizeof(struct omap_dma_s));
if (model <= omap_dma_3_1) {
num_irqs = 6;
@@ -2039,7 +2039,7 @@ struct soc_dma_s *omap_dma4_init(target_phys_addr_t base, qemu_irq *irqs,
{
int iomemtype, i;
struct omap_dma_s *s = (struct omap_dma_s *)
- qemu_mallocz(sizeof(struct omap_dma_s));
+ g_malloc0(sizeof(struct omap_dma_s));
s->model = omap_dma_4;
s->chans = chans;
diff --git a/hw/omap_dss.c b/hw/omap_dss.c
index afe287a43..c8387a8cc 100644
--- a/hw/omap_dss.c
+++ b/hw/omap_dss.c
@@ -627,7 +627,7 @@ static void omap_rfbi_transfer_start(struct omap_dss_s *s)
}
if (!data) {
if (len > bounce_len) {
- bounce_buffer = qemu_realloc(bounce_buffer, len);
+ bounce_buffer = g_realloc(bounce_buffer, len);
}
data = bounce_buffer;
cpu_physical_memory_read(data_addr, data, len);
@@ -1030,7 +1030,7 @@ struct omap_dss_s *omap_dss_init(struct omap_target_agent_s *ta,
{
int iomemtype[5];
struct omap_dss_s *s = (struct omap_dss_s *)
- qemu_mallocz(sizeof(struct omap_dss_s));
+ g_malloc0(sizeof(struct omap_dss_s));
s->irq = irq;
s->drq = drq;
diff --git a/hw/omap_gpio.c b/hw/omap_gpio.c
index c23964c66..42e59c3a5 100644
--- a/hw/omap_gpio.c
+++ b/hw/omap_gpio.c
@@ -696,8 +696,8 @@ static int omap2_gpio_init(SysBusDevice *dev)
} else {
s->modulecount = 6;
}
- s->modules = qemu_mallocz(s->modulecount * sizeof(struct omap2_gpio_s));
- s->handler = qemu_mallocz(s->modulecount * 32 * sizeof(qemu_irq));
+ s->modules = g_malloc0(s->modulecount * sizeof(struct omap2_gpio_s));
+ s->handler = g_malloc0(s->modulecount * 32 * sizeof(qemu_irq));
qdev_init_gpio_in(&dev->qdev, omap2_gpio_set, s->modulecount * 32);
qdev_init_gpio_out(&dev->qdev, s->handler, s->modulecount * 32);
for (i = 0; i < s->modulecount; i++) {
diff --git a/hw/omap_gpmc.c b/hw/omap_gpmc.c
index 8bf3343a6..13e3e00b6 100644
--- a/hw/omap_gpmc.c
+++ b/hw/omap_gpmc.c
@@ -385,7 +385,7 @@ struct omap_gpmc_s *omap_gpmc_init(target_phys_addr_t base, qemu_irq irq)
{
int iomemtype;
struct omap_gpmc_s *s = (struct omap_gpmc_s *)
- qemu_mallocz(sizeof(struct omap_gpmc_s));
+ g_malloc0(sizeof(struct omap_gpmc_s));
omap_gpmc_reset(s);
diff --git a/hw/omap_gptimer.c b/hw/omap_gptimer.c
index f2a424f27..704b00063 100644
--- a/hw/omap_gptimer.c
+++ b/hw/omap_gptimer.c
@@ -465,7 +465,7 @@ struct omap_gp_timer_s *omap_gp_timer_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_gp_timer_s *s = (struct omap_gp_timer_s *)
- qemu_mallocz(sizeof(struct omap_gp_timer_s));
+ g_malloc0(sizeof(struct omap_gp_timer_s));
s->ta = ta;
s->irq = irq;
diff --git a/hw/omap_i2c.c b/hw/omap_i2c.c
index 5cabb5a7b..11577b1ee 100644
--- a/hw/omap_i2c.c
+++ b/hw/omap_i2c.c
@@ -426,7 +426,7 @@ struct omap_i2c_s *omap_i2c_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_i2c_s *s = (struct omap_i2c_s *)
- qemu_mallocz(sizeof(struct omap_i2c_s));
+ g_malloc0(sizeof(struct omap_i2c_s));
/* TODO: set a value greater or equal to real hardware */
s->revision = 0x11;
@@ -448,7 +448,7 @@ struct omap_i2c_s *omap2_i2c_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_i2c_s *s = (struct omap_i2c_s *)
- qemu_mallocz(sizeof(struct omap_i2c_s));
+ g_malloc0(sizeof(struct omap_i2c_s));
s->revision = 0x34;
s->irq = irq;
diff --git a/hw/omap_intc.c b/hw/omap_intc.c
index 001e20b9d..f1f570e4a 100644
--- a/hw/omap_intc.c
+++ b/hw/omap_intc.c
@@ -358,7 +358,7 @@ struct omap_intr_handler_s *omap_inth_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_intr_handler_s *s = (struct omap_intr_handler_s *)
- qemu_mallocz(sizeof(struct omap_intr_handler_s) +
+ g_malloc0(sizeof(struct omap_intr_handler_s) +
sizeof(struct omap_intr_handler_bank_s) * nbanks);
s->parent_intr[0] = parent_irq;
@@ -577,7 +577,7 @@ struct omap_intr_handler_s *omap2_inth_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_intr_handler_s *s = (struct omap_intr_handler_s *)
- qemu_mallocz(sizeof(struct omap_intr_handler_s) +
+ g_malloc0(sizeof(struct omap_intr_handler_s) +
sizeof(struct omap_intr_handler_bank_s) * nbanks);
s->parent_intr[0] = parent_irq;
diff --git a/hw/omap_l4.c b/hw/omap_l4.c
index 59c84b19a..a4a8883d2 100644
--- a/hw/omap_l4.c
+++ b/hw/omap_l4.c
@@ -120,7 +120,7 @@ struct omap_l4_s {
struct omap_l4_s *omap_l4_init(target_phys_addr_t base, int ta_num)
{
- struct omap_l4_s *bus = qemu_mallocz(
+ struct omap_l4_s *bus = g_malloc0(
sizeof(*bus) + ta_num * sizeof(*bus->ta));
bus->ta_num = ta_num;
@@ -128,19 +128,19 @@ struct omap_l4_s *omap_l4_init(target_phys_addr_t base, int ta_num)
#ifdef L4_MUX_HACK
omap_l4_io_entries = 1;
- omap_l4_io_entry = qemu_mallocz(125 * sizeof(*omap_l4_io_entry));
+ omap_l4_io_entry = g_malloc0(125 * sizeof(*omap_l4_io_entry));
omap_cpu_io_entry =
cpu_register_io_memory(omap_l4_io_readfn,
omap_l4_io_writefn, bus, DEVICE_NATIVE_ENDIAN);
# define L4_PAGES (0xb4000 / TARGET_PAGE_SIZE)
- omap_l4_io_readb_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
- omap_l4_io_readh_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
- omap_l4_io_readw_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
- omap_l4_io_writeb_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
- omap_l4_io_writeh_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
- omap_l4_io_writew_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
- omap_l4_io_opaque = qemu_mallocz(sizeof(void *) * L4_PAGES);
+ omap_l4_io_readb_fn = g_malloc0(sizeof(void *) * L4_PAGES);
+ omap_l4_io_readh_fn = g_malloc0(sizeof(void *) * L4_PAGES);
+ omap_l4_io_readw_fn = g_malloc0(sizeof(void *) * L4_PAGES);
+ omap_l4_io_writeb_fn = g_malloc0(sizeof(void *) * L4_PAGES);
+ omap_l4_io_writeh_fn = g_malloc0(sizeof(void *) * L4_PAGES);
+ omap_l4_io_writew_fn = g_malloc0(sizeof(void *) * L4_PAGES);
+ omap_l4_io_opaque = g_malloc0(sizeof(void *) * L4_PAGES);
#endif
return bus;
diff --git a/hw/omap_lcdc.c b/hw/omap_lcdc.c
index 0c2c55012..a9054227e 100644
--- a/hw/omap_lcdc.c
+++ b/hw/omap_lcdc.c
@@ -441,7 +441,7 @@ struct omap_lcd_panel_s *omap_lcdc_init(target_phys_addr_t base, qemu_irq irq,
{
int iomemtype;
struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *)
- qemu_mallocz(sizeof(struct omap_lcd_panel_s));
+ g_malloc0(sizeof(struct omap_lcd_panel_s));
s->irq = irq;
s->dma = dma;
diff --git a/hw/omap_mmc.c b/hw/omap_mmc.c
index e9ec2f398..a1afeb5c9 100644
--- a/hw/omap_mmc.c
+++ b/hw/omap_mmc.c
@@ -576,7 +576,7 @@ struct omap_mmc_s *omap_mmc_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_mmc_s *s = (struct omap_mmc_s *)
- qemu_mallocz(sizeof(struct omap_mmc_s));
+ g_malloc0(sizeof(struct omap_mmc_s));
s->irq = irq;
s->dma = dma;
@@ -602,7 +602,7 @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_mmc_s *s = (struct omap_mmc_s *)
- qemu_mallocz(sizeof(struct omap_mmc_s));
+ g_malloc0(sizeof(struct omap_mmc_s));
s->irq = irq;
s->dma = dma;
diff --git a/hw/omap_sdrc.c b/hw/omap_sdrc.c
index e18376260..1df2fd82b 100644
--- a/hw/omap_sdrc.c
+++ b/hw/omap_sdrc.c
@@ -153,7 +153,7 @@ struct omap_sdrc_s *omap_sdrc_init(target_phys_addr_t base)
{
int iomemtype;
struct omap_sdrc_s *s = (struct omap_sdrc_s *)
- qemu_mallocz(sizeof(struct omap_sdrc_s));
+ g_malloc0(sizeof(struct omap_sdrc_s));
omap_sdrc_reset(s);
diff --git a/hw/omap_spi.c b/hw/omap_spi.c
index a6b03496c..6030ad955 100644
--- a/hw/omap_spi.c
+++ b/hw/omap_spi.c
@@ -315,7 +315,7 @@ struct omap_mcspi_s *omap_mcspi_init(struct omap_target_agent_s *ta, int chnum,
{
int iomemtype;
struct omap_mcspi_s *s = (struct omap_mcspi_s *)
- qemu_mallocz(sizeof(struct omap_mcspi_s));
+ g_malloc0(sizeof(struct omap_mcspi_s));
struct omap_mcspi_ch_s *ch = s->ch;
s->irq = irq;
diff --git a/hw/omap_synctimer.c b/hw/omap_synctimer.c
index 67f65e6da..b47ca8819 100644
--- a/hw/omap_synctimer.c
+++ b/hw/omap_synctimer.c
@@ -86,7 +86,7 @@ static CPUWriteMemoryFunc * const omap_synctimer_writefn[] = {
struct omap_synctimer_s *omap_synctimer_init(struct omap_target_agent_s *ta,
struct omap_mpu_state_s *mpu, omap_clk fclk, omap_clk iclk)
{
- struct omap_synctimer_s *s = qemu_mallocz(sizeof(*s));
+ struct omap_synctimer_s *s = g_malloc0(sizeof(*s));
omap_synctimer_reset(s);
omap_l4_attach(ta, 0, l4_register_io_memory(
diff --git a/hw/omap_uart.c b/hw/omap_uart.c
index 9cee81d7c..09ae9f8ab 100644
--- a/hw/omap_uart.c
+++ b/hw/omap_uart.c
@@ -55,7 +55,7 @@ struct omap_uart_s *omap_uart_init(target_phys_addr_t base,
const char *label, CharDriverState *chr)
{
struct omap_uart_s *s = (struct omap_uart_s *)
- qemu_mallocz(sizeof(struct omap_uart_s));
+ g_malloc0(sizeof(struct omap_uart_s));
s->base = base;
s->fclk = fclk;
diff --git a/hw/onenand.c b/hw/onenand.c
index b0cbebc17..c37cf59be 100644
--- a/hw/onenand.c
+++ b/hw/onenand.c
@@ -186,7 +186,7 @@ static inline int onenand_prog_main(OneNANDState *s, int sec, int secn,
const uint8_t *sp = (const uint8_t *) src;
uint8_t *dp = 0;
if (s->bdrv_cur) {
- dp = qemu_malloc(size);
+ dp = g_malloc(size);
if (!dp || bdrv_read(s->bdrv_cur, sec, dp, secn) < 0) {
result = 1;
}
@@ -207,7 +207,7 @@ static inline int onenand_prog_main(OneNANDState *s, int sec, int secn,
}
}
if (dp && s->bdrv_cur) {
- qemu_free(dp);
+ g_free(dp);
}
}
@@ -239,7 +239,7 @@ static inline int onenand_prog_spare(OneNANDState *s, int sec, int secn,
const uint8_t *sp = (const uint8_t *) src;
uint8_t *dp = 0, *dpp = 0;
if (s->bdrv_cur) {
- dp = qemu_malloc(512);
+ dp = g_malloc(512);
if (!dp || bdrv_read(s->bdrv_cur,
s->secs_cur + (sec >> 5),
dp, 1) < 0) {
@@ -265,7 +265,7 @@ static inline int onenand_prog_spare(OneNANDState *s, int sec, int secn,
}
}
if (dp) {
- qemu_free(dp);
+ g_free(dp);
}
}
return result;
@@ -274,13 +274,13 @@ static inline int onenand_prog_spare(OneNANDState *s, int sec, int secn,
static inline int onenand_erase(OneNANDState *s, int sec, int num)
{
uint8_t *blankbuf, *tmpbuf;
- blankbuf = qemu_malloc(512);
+ blankbuf = g_malloc(512);
if (!blankbuf) {
return 1;
}
- tmpbuf = qemu_malloc(512);
+ tmpbuf = g_malloc(512);
if (!tmpbuf) {
- qemu_free(blankbuf);
+ g_free(blankbuf);
return 1;
}
memset(blankbuf, 0xff, 512);
@@ -307,13 +307,13 @@ static inline int onenand_erase(OneNANDState *s, int sec, int num)
}
}
- qemu_free(tmpbuf);
- qemu_free(blankbuf);
+ g_free(tmpbuf);
+ g_free(blankbuf);
return 0;
fail:
- qemu_free(tmpbuf);
- qemu_free(blankbuf);
+ g_free(tmpbuf);
+ g_free(blankbuf);
return 1;
}
@@ -700,7 +700,7 @@ void *onenand_init(BlockDriverState *bdrv,
uint16_t man_id, uint16_t dev_id, uint16_t ver_id,
int regshift, qemu_irq irq)
{
- OneNANDState *s = (OneNANDState *) qemu_mallocz(sizeof(*s));
+ OneNANDState *s = (OneNANDState *) g_malloc0(sizeof(*s));
uint32_t size = 1 << (24 + ((dev_id >> 4) & 7));
void *ram;
@@ -712,16 +712,16 @@ void *onenand_init(BlockDriverState *bdrv,
s->id.ver = ver_id;
s->blocks = size >> BLOCK_SHIFT;
s->secs = size >> 9;
- s->blockwp = qemu_malloc(s->blocks);
+ s->blockwp = g_malloc(s->blocks);
s->density_mask = (dev_id & 0x08) ? (1 << (6 + ((dev_id >> 4) & 7))) : 0;
s->iomemtype = cpu_register_io_memory(onenand_readfn,
onenand_writefn, s, DEVICE_NATIVE_ENDIAN);
s->bdrv = bdrv;
if (!s->bdrv) {
- s->image = memset(qemu_malloc(size + (size >> 5)),
+ s->image = memset(g_malloc(size + (size >> 5)),
0xff, size + (size >> 5));
}
- s->otp = memset(qemu_malloc((64 + 2) << PAGE_SHIFT),
+ s->otp = memset(g_malloc((64 + 2) << PAGE_SHIFT),
0xff, (64 + 2) << PAGE_SHIFT);
s->ram = qemu_ram_alloc(NULL, "onenand.ram", 0xc000 << s->shift);
ram = qemu_get_ram_ptr(s->ram);
diff --git a/hw/openpic.c b/hw/openpic.c
index ccd4a14f8..26c96e20f 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -1180,7 +1180,7 @@ qemu_irq *openpic_init (PCIBus *bus, MemoryRegion **pmem, int nb_cpus,
pci_register_bar(&opp->pci_dev, 0,
PCI_BASE_ADDRESS_SPACE_MEMORY, &opp->mem);
} else {
- opp = qemu_mallocz(sizeof(openpic_t));
+ opp = g_malloc0(sizeof(openpic_t));
memory_region_init_io(&opp->mem, &openpic_ops, opp, "openpic", 0x40000);
}
@@ -1644,7 +1644,7 @@ qemu_irq *mpic_init (target_phys_addr_t base, int nb_cpus,
if (nb_cpus != 1)
return NULL;
- mpp = qemu_mallocz(sizeof(openpic_t));
+ mpp = g_malloc0(sizeof(openpic_t));
for (i = 0; i < sizeof(list)/sizeof(list[0]); i++) {
int mem_index;
@@ -1676,6 +1676,6 @@ qemu_irq *mpic_init (target_phys_addr_t base, int nb_cpus,
return qemu_allocate_irqs(openpic_set_irq, mpp, mpp->max_irq);
free:
- qemu_free(mpp);
+ g_free(mpp);
return NULL;
}
diff --git a/hw/parallel.c b/hw/parallel.c
index cc853a57d..71f30ea1e 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -565,7 +565,7 @@ bool parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
ParallelState *s;
int io_sw;
- s = qemu_mallocz(sizeof(ParallelState));
+ s = g_malloc0(sizeof(ParallelState));
s->irq = irq;
s->chr = chr;
s->it_shift = it_shift;
diff --git a/hw/pc.c b/hw/pc.c
index 4b07b35e0..7be60a4a0 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -617,7 +617,7 @@ static void *bochs_bios_init(void)
* of nodes, one word for each VCPU->node and one word for each node to
* hold the amount of memory.
*/
- numa_fw_cfg = qemu_mallocz((1 + smp_cpus + nb_numa_nodes) * 8);
+ numa_fw_cfg = g_malloc0((1 + smp_cpus + nb_numa_nodes) * 8);
numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes);
for (i = 0; i < smp_cpus; i++) {
for (j = 0; j < nb_numa_nodes; j++) {
@@ -788,7 +788,7 @@ static void load_linux(void *fw_cfg,
initrd_addr = (initrd_max-initrd_size) & ~4095;
- initrd_data = qemu_malloc(initrd_size);
+ initrd_data = g_malloc(initrd_size);
load_image(initrd_filename, initrd_data);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr);
@@ -806,8 +806,8 @@ static void load_linux(void *fw_cfg,
setup_size = (setup_size+1)*512;
kernel_size -= setup_size;
- setup = qemu_malloc(setup_size);
- kernel = qemu_malloc(kernel_size);
+ setup = g_malloc(setup_size);
+ kernel = g_malloc(kernel_size);
fseek(f, 0, SEEK_SET);
if (fread(setup, 1, setup_size, f) != setup_size) {
fprintf(stderr, "fread() failed\n");
@@ -978,15 +978,15 @@ void pc_memory_init(MemoryRegion *system_memory,
* aliases to address portions of it, mostly for backwards compatiblity
* with older qemus that used qemu_ram_alloc().
*/
- ram = qemu_malloc(sizeof(*ram));
+ ram = g_malloc(sizeof(*ram));
memory_region_init_ram(ram, NULL, "pc.ram",
below_4g_mem_size + above_4g_mem_size);
- ram_below_4g = qemu_malloc(sizeof(*ram_below_4g));
+ ram_below_4g = g_malloc(sizeof(*ram_below_4g));
memory_region_init_alias(ram_below_4g, "ram-below-4g", ram,
0, below_4g_mem_size);
memory_region_add_subregion(system_memory, 0, ram_below_4g);
if (above_4g_mem_size > 0) {
- ram_above_4g = qemu_malloc(sizeof(*ram_above_4g));
+ ram_above_4g = g_malloc(sizeof(*ram_above_4g));
memory_region_init_alias(ram_above_4g, "ram-above-4g", ram,
below_4g_mem_size, above_4g_mem_size);
memory_region_add_subregion(system_memory, 0x100000000ULL,
@@ -1006,7 +1006,7 @@ void pc_memory_init(MemoryRegion *system_memory,
(bios_size % 65536) != 0) {
goto bios_error;
}
- bios = qemu_malloc(sizeof(*bios));
+ bios = g_malloc(sizeof(*bios));
memory_region_init_ram(bios, NULL, "pc.bios", bios_size);
memory_region_set_readonly(bios, true);
ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
@@ -1016,13 +1016,13 @@ void pc_memory_init(MemoryRegion *system_memory,
exit(1);
}
if (filename) {
- qemu_free(filename);
+ g_free(filename);
}
/* map the last 128KB of the BIOS in ISA space */
isa_bios_size = bios_size;
if (isa_bios_size > (128 * 1024))
isa_bios_size = 128 * 1024;
- isa_bios = qemu_malloc(sizeof(*isa_bios));
+ isa_bios = g_malloc(sizeof(*isa_bios));
memory_region_init_alias(isa_bios, "isa-bios", bios,
bios_size - isa_bios_size, isa_bios_size);
memory_region_add_subregion_overlap(system_memory,
@@ -1031,7 +1031,7 @@ void pc_memory_init(MemoryRegion *system_memory,
1);
memory_region_set_readonly(isa_bios, true);
- option_rom_mr = qemu_malloc(sizeof(*option_rom_mr));
+ option_rom_mr = g_malloc(sizeof(*option_rom_mr));
memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE);
memory_region_add_subregion_overlap(system_memory,
PC_ROM_MIN_VGA,
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 7dd5008dc..a9fe5964d 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -121,7 +121,7 @@ static void pc_init1(MemoryRegion *system_memory,
} else {
i8259 = xen_interrupt_controller_init();
}
- isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state));
+ isa_irq_state = g_malloc0(sizeof(*isa_irq_state));
isa_irq_state->i8259 = i8259;
if (pci_enabled) {
ioapic_init(isa_irq_state);
diff --git a/hw/pci.c b/hw/pci.c
index dc7271a19..4dc13d256 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -223,7 +223,7 @@ static int pcibus_reset(BusState *qbus)
static void pci_host_bus_register(int domain, PCIBus *bus)
{
struct PCIHostBus *host;
- host = qemu_mallocz(sizeof(*host));
+ host = g_malloc0(sizeof(*host));
host->domain = domain;
host->bus = bus;
QLIST_INSERT_HEAD(&host_buses, host, next);
@@ -288,7 +288,7 @@ PCIBus *pci_bus_new(DeviceState *parent, const char *name,
{
PCIBus *bus;
- bus = qemu_mallocz(sizeof(*bus));
+ bus = g_malloc0(sizeof(*bus));
bus->qbus.qdev_allocated = 1;
pci_bus_new_inplace(bus, parent, name, address_space_mem,
address_space_io, devfn_min);
@@ -302,7 +302,7 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
bus->map_irq = map_irq;
bus->irq_opaque = irq_opaque;
bus->nirq = nirq;
- bus->irq_count = qemu_mallocz(nirq * sizeof(bus->irq_count[0]));
+ bus->irq_count = g_malloc0(nirq * sizeof(bus->irq_count[0]));
}
void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug, DeviceState *qdev)
@@ -346,13 +346,13 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
int i;
assert(size == pci_config_size(s));
- config = qemu_malloc(size);
+ config = g_malloc(size);
qemu_get_buffer(f, config, size);
for (i = 0; i < size; ++i) {
if ((config[i] ^ s->config[i]) &
s->cmask[i] & ~s->wmask[i] & ~s->w1cmask[i]) {
- qemu_free(config);
+ g_free(config);
return -EINVAL;
}
}
@@ -360,7 +360,7 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
pci_update_mappings(s);
- qemu_free(config);
+ g_free(config);
return 0;
}
@@ -720,20 +720,20 @@ static void pci_config_alloc(PCIDevice *pci_dev)
{
int config_size = pci_config_size(pci_dev);
- pci_dev->config = qemu_mallocz(config_size);
- pci_dev->cmask = qemu_mallocz(config_size);
- pci_dev->wmask = qemu_mallocz(config_size);
- pci_dev->w1cmask = qemu_mallocz(config_size);
- pci_dev->used = qemu_mallocz(config_size);
+ pci_dev->config = g_malloc0(config_size);
+ pci_dev->cmask = g_malloc0(config_size);
+ pci_dev->wmask = g_malloc0(config_size);
+ pci_dev->w1cmask = g_malloc0(config_size);
+ pci_dev->used = g_malloc0(config_size);
}
static void pci_config_free(PCIDevice *pci_dev)
{
- qemu_free(pci_dev->config);
- qemu_free(pci_dev->cmask);
- qemu_free(pci_dev->wmask);
- qemu_free(pci_dev->w1cmask);
- qemu_free(pci_dev->used);
+ g_free(pci_dev->config);
+ g_free(pci_dev->cmask);
+ g_free(pci_dev->wmask);
+ g_free(pci_dev->w1cmask);
+ g_free(pci_dev->used);
}
/* -1 for devfn means auto assign */
@@ -825,7 +825,7 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name,
.config_write = config_write,
};
- pci_dev = qemu_mallocz(instance_size);
+ pci_dev = g_malloc0(instance_size);
pci_dev = do_pci_register_device(pci_dev, bus, name, devfn, &info);
if (pci_dev == NULL) {
hw_error("PCI: can't register device\n");
@@ -865,7 +865,7 @@ static int pci_unregister_device(DeviceState *dev)
pci_unregister_io_regions(pci_dev);
pci_del_option_rom(pci_dev);
- qemu_free(pci_dev->romfile);
+ g_free(pci_dev->romfile);
do_pci_unregister_device(pci_dev);
return 0;
}
@@ -1680,7 +1680,7 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
/* rom loading */
is_default_rom = false;
if (pci_dev->romfile == NULL && info->romfile != NULL) {
- pci_dev->romfile = qemu_strdup(info->romfile);
+ pci_dev->romfile = g_strdup(info->romfile);
is_default_rom = true;
}
pci_add_option_rom(pci_dev, is_default_rom);
@@ -1896,14 +1896,14 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);
if (path == NULL) {
- path = qemu_strdup(pdev->romfile);
+ path = g_strdup(pdev->romfile);
}
size = get_image_size(path);
if (size < 0) {
error_report("%s: failed to find romfile \"%s\"",
__FUNCTION__, pdev->romfile);
- qemu_free(path);
+ g_free(path);
return -1;
}
if (size & (size - 1)) {
@@ -1918,7 +1918,7 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
memory_region_init_ram(&pdev->rom, &pdev->qdev, name, size);
ptr = memory_region_get_ram_ptr(&pdev->rom);
load_image(path, ptr);
- qemu_free(path);
+ g_free(path);
if (is_default_rom) {
/* Only the default rom images will be patched (if needed). */
@@ -2108,7 +2108,7 @@ static char *pcibus_get_dev_path(DeviceState *dev)
path_len = domain_len + slot_len * slot_depth;
/* Allocate memory, fill in the terminating null byte. */
- path = qemu_malloc(path_len + 1 /* For '\0' */);
+ path = g_malloc(path_len + 1 /* For '\0' */);
path[path_len] = '\0';
/* First field is the domain. */
diff --git a/hw/pcie_aer.c b/hw/pcie_aer.c
index be019c7c0..2ae65ec80 100644
--- a/hw/pcie_aer.c
+++ b/hw/pcie_aer.c
@@ -111,7 +111,7 @@ int pcie_aer_init(PCIDevice *dev, uint16_t offset)
if (dev->exp.aer_log.log_max > PCIE_AER_LOG_MAX_LIMIT) {
return -EINVAL;
}
- dev->exp.aer_log.log = qemu_mallocz(sizeof dev->exp.aer_log.log[0] *
+ dev->exp.aer_log.log = g_malloc0(sizeof dev->exp.aer_log.log[0] *
dev->exp.aer_log.log_max);
pci_set_long(dev->w1cmask + offset + PCI_ERR_UNCOR_STATUS,
@@ -165,7 +165,7 @@ int pcie_aer_init(PCIDevice *dev, uint16_t offset)
void pcie_aer_exit(PCIDevice *dev)
{
- qemu_free(dev->exp.aer_log.log);
+ g_free(dev->exp.aer_log.log);
}
static void pcie_aer_update_uncor_status(PCIDevice *dev)
diff --git a/hw/pcie_port.c b/hw/pcie_port.c
index 340dcdb3c..8a36f5cfc 100644
--- a/hw/pcie_port.c
+++ b/hw/pcie_port.c
@@ -76,7 +76,7 @@ void pcie_chassis_create(uint8_t chassis_number)
if (c) {
return;
}
- c = qemu_mallocz(sizeof(*c));
+ c = g_malloc0(sizeof(*c));
c->number = chassis_number;
QLIST_INIT(&c->slots);
QLIST_INSERT_HEAD(&chassis, c, next);
diff --git a/hw/pckbd.c b/hw/pckbd.c
index ae65c04da..a272ccdb7 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -416,7 +416,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
target_phys_addr_t base, ram_addr_t size,
target_phys_addr_t mask)
{
- KBDState *s = qemu_mallocz(sizeof(KBDState));
+ KBDState *s = g_malloc0(sizeof(KBDState));
int s_io_memory;
s->irq_kbd = kbd_irq;
diff --git a/hw/petalogix_ml605_mmu.c b/hw/petalogix_ml605_mmu.c
index 8213902fb..e3a66e51b 100644
--- a/hw/petalogix_ml605_mmu.c
+++ b/hw/petalogix_ml605_mmu.c
@@ -88,7 +88,7 @@ static int petalogix_load_device_tree(target_phys_addr_t addr,
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (path) {
fdt = load_device_tree(path, &fdt_size);
- qemu_free(path);
+ g_free(path);
}
if (!fdt) {
return 0;
@@ -108,7 +108,7 @@ static int petalogix_load_device_tree(target_phys_addr_t addr,
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (path) {
fdt_size = load_image_targphys(path, addr, 0x10000);
- qemu_free(path);
+ g_free(path);
}
}
diff --git a/hw/petalogix_s3adsp1800_mmu.c b/hw/petalogix_s3adsp1800_mmu.c
index 4dcdfbd3c..589e8cabb 100644
--- a/hw/petalogix_s3adsp1800_mmu.c
+++ b/hw/petalogix_s3adsp1800_mmu.c
@@ -75,7 +75,7 @@ static int petalogix_load_device_tree(target_phys_addr_t addr,
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (path) {
fdt = load_device_tree(path, &fdt_size);
- qemu_free(path);
+ g_free(path);
}
if (!fdt)
return 0;
@@ -93,7 +93,7 @@ static int petalogix_load_device_tree(target_phys_addr_t addr,
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (path) {
fdt_size = load_image_targphys(path, addr, 0x10000);
- qemu_free(path);
+ g_free(path);
}
}
diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c
index 90fdc84f1..90e1301c5 100644
--- a/hw/pflash_cfi01.c
+++ b/hw/pflash_cfi01.c
@@ -594,7 +594,7 @@ pflash_t *pflash_cfi01_register(target_phys_addr_t base, ram_addr_t off,
return NULL;
#endif
- pfl = qemu_mallocz(sizeof(pflash_t));
+ pfl = g_malloc0(sizeof(pflash_t));
/* FIXME: Allocate ram ourselves. */
pfl->storage = qemu_get_ram_ptr(off);
@@ -617,7 +617,7 @@ pflash_t *pflash_cfi01_register(target_phys_addr_t base, ram_addr_t off,
ret = bdrv_read(pfl->bs, 0, pfl->storage, total_len >> 9);
if (ret < 0) {
cpu_unregister_io_memory(pfl->fl_mem);
- qemu_free(pfl);
+ g_free(pfl);
return NULL;
}
}
diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c
index 725cd1e78..ac5115e4c 100644
--- a/hw/pflash_cfi02.c
+++ b/hw/pflash_cfi02.c
@@ -617,7 +617,7 @@ pflash_t *pflash_cfi02_register(target_phys_addr_t base, ram_addr_t off,
total_len != (32 * 1024 * 1024) && total_len != (64 * 1024 * 1024))
return NULL;
#endif
- pfl = qemu_mallocz(sizeof(pflash_t));
+ pfl = g_malloc0(sizeof(pflash_t));
/* FIXME: Allocate ram ourselves. */
pfl->storage = qemu_get_ram_ptr(off);
if (be) {
@@ -640,7 +640,7 @@ pflash_t *pflash_cfi02_register(target_phys_addr_t base, ram_addr_t off,
ret = bdrv_read(pfl->bs, 0, pfl->storage, chip_len >> 9);
if (ret < 0) {
cpu_unregister_io_memory(pfl->fl_mem);
- qemu_free(pfl);
+ g_free(pfl);
return NULL;
}
}
diff --git a/hw/ppc.c b/hw/ppc.c
index 915771944..887074822 100644
--- a/hw/ppc.c
+++ b/hw/ppc.c
@@ -761,7 +761,7 @@ clk_setup_cb cpu_ppc_tb_init (CPUState *env, uint32_t freq)
{
ppc_tb_t *tb_env;
- tb_env = qemu_mallocz(sizeof(ppc_tb_t));
+ tb_env = g_malloc0(sizeof(ppc_tb_t));
env->tb_env = tb_env;
/* Create new timer */
tb_env->decr_timer = qemu_new_timer_ns(vm_clock, &cpu_ppc_decr_cb, env);
@@ -1038,9 +1038,9 @@ clk_setup_cb ppc_emb_timers_init (CPUState *env, uint32_t freq,
ppc_tb_t *tb_env;
ppcemb_timer_t *ppcemb_timer;
- tb_env = qemu_mallocz(sizeof(ppc_tb_t));
+ tb_env = g_malloc0(sizeof(ppc_tb_t));
env->tb_env = tb_env;
- ppcemb_timer = qemu_mallocz(sizeof(ppcemb_timer_t));
+ ppcemb_timer = g_malloc0(sizeof(ppcemb_timer_t));
tb_env->tb_freq = freq;
tb_env->decr_freq = freq;
tb_env->opaque = ppcemb_timer;
@@ -1145,7 +1145,7 @@ int ppc_dcr_init (CPUState *env, int (*read_error)(int dcrn),
{
ppc_dcr_t *dcr_env;
- dcr_env = qemu_mallocz(sizeof(ppc_dcr_t));
+ dcr_env = g_malloc0(sizeof(ppc_dcr_t));
dcr_env->read_error = read_error;
dcr_env->write_error = write_error;
env->dcr_env = dcr_env;
diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c
index ad2718102..34f935086 100644
--- a/hw/ppc405_boards.c
+++ b/hw/ppc405_boards.c
@@ -162,7 +162,7 @@ static void ref405ep_fpga_init (uint32_t base)
ref405ep_fpga_t *fpga;
int fpga_memory;
- fpga = qemu_mallocz(sizeof(ref405ep_fpga_t));
+ fpga = g_malloc0(sizeof(ref405ep_fpga_t));
fpga_memory = cpu_register_io_memory(ref405ep_fpga_read,
ref405ep_fpga_write, fpga,
DEVICE_NATIVE_ENDIAN);
@@ -246,7 +246,7 @@ static void ref405ep_init (ram_addr_t ram_size,
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image(filename, qemu_get_ram_ptr(bios_offset));
- qemu_free(filename);
+ g_free(filename);
} else {
bios_size = -1;
}
@@ -487,7 +487,7 @@ static void taihu_cpld_init (uint32_t base)
taihu_cpld_t *cpld;
int cpld_memory;
- cpld = qemu_mallocz(sizeof(taihu_cpld_t));
+ cpld = g_malloc0(sizeof(taihu_cpld_t));
cpld_memory = cpu_register_io_memory(taihu_cpld_read,
taihu_cpld_write, cpld,
DEVICE_NATIVE_ENDIAN);
@@ -560,7 +560,7 @@ static void taihu_405ep_init(ram_addr_t ram_size,
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image(filename, qemu_get_ram_ptr(bios_offset));
- qemu_free(filename);
+ g_free(filename);
} else {
bios_size = -1;
}
diff --git a/hw/ppc405_uc.c b/hw/ppc405_uc.c
index 06a053bf0..68c7cbd3a 100644
--- a/hw/ppc405_uc.c
+++ b/hw/ppc405_uc.c
@@ -172,7 +172,7 @@ static void ppc4xx_plb_init(CPUState *env)
{
ppc4xx_plb_t *plb;
- plb = qemu_mallocz(sizeof(ppc4xx_plb_t));
+ plb = g_malloc0(sizeof(ppc4xx_plb_t));
ppc_dcr_register(env, PLB0_ACR, plb, &dcr_read_plb, &dcr_write_plb);
ppc_dcr_register(env, PLB0_BEAR, plb, &dcr_read_plb, &dcr_write_plb);
ppc_dcr_register(env, PLB0_BESR, plb, &dcr_read_plb, &dcr_write_plb);
@@ -248,7 +248,7 @@ static void ppc4xx_pob_init(CPUState *env)
{
ppc4xx_pob_t *pob;
- pob = qemu_mallocz(sizeof(ppc4xx_pob_t));
+ pob = g_malloc0(sizeof(ppc4xx_pob_t));
ppc_dcr_register(env, POB0_BEAR, pob, &dcr_read_pob, &dcr_write_pob);
ppc_dcr_register(env, POB0_BESR0, pob, &dcr_read_pob, &dcr_write_pob);
ppc_dcr_register(env, POB0_BESR1, pob, &dcr_read_pob, &dcr_write_pob);
@@ -383,7 +383,7 @@ static void ppc4xx_opba_init(target_phys_addr_t base)
ppc4xx_opba_t *opba;
int io;
- opba = qemu_mallocz(sizeof(ppc4xx_opba_t));
+ opba = g_malloc0(sizeof(ppc4xx_opba_t));
#ifdef DEBUG_OPBA
printf("%s: offset " TARGET_FMT_plx "\n", __func__, base);
#endif
@@ -582,7 +582,7 @@ static void ppc405_ebc_init(CPUState *env)
{
ppc4xx_ebc_t *ebc;
- ebc = qemu_mallocz(sizeof(ppc4xx_ebc_t));
+ ebc = g_malloc0(sizeof(ppc4xx_ebc_t));
qemu_register_reset(&ebc_reset, ebc);
ppc_dcr_register(env, EBC0_CFGADDR,
ebc, &dcr_read_ebc, &dcr_write_ebc);
@@ -665,7 +665,7 @@ static void ppc405_dma_init(CPUState *env, qemu_irq irqs[4])
{
ppc405_dma_t *dma;
- dma = qemu_mallocz(sizeof(ppc405_dma_t));
+ dma = g_malloc0(sizeof(ppc405_dma_t));
memcpy(dma->irqs, irqs, 4 * sizeof(qemu_irq));
qemu_register_reset(&ppc405_dma_reset, dma);
ppc_dcr_register(env, DMA0_CR0,
@@ -810,7 +810,7 @@ static void ppc405_gpio_init(target_phys_addr_t base)
ppc405_gpio_t *gpio;
int io;
- gpio = qemu_mallocz(sizeof(ppc405_gpio_t));
+ gpio = g_malloc0(sizeof(ppc405_gpio_t));
#ifdef DEBUG_GPIO
printf("%s: offset " TARGET_FMT_plx "\n", __func__, base);
#endif
@@ -972,7 +972,7 @@ static void ppc405_ocm_init(CPUState *env)
{
ppc405_ocm_t *ocm;
- ocm = qemu_mallocz(sizeof(ppc405_ocm_t));
+ ocm = g_malloc0(sizeof(ppc405_ocm_t));
ocm->offset = qemu_ram_alloc(NULL, "ppc405.ocm", 4096);
qemu_register_reset(&ocm_reset, ocm);
ppc_dcr_register(env, OCM0_ISARC,
@@ -1219,7 +1219,7 @@ static void ppc405_i2c_init(target_phys_addr_t base, qemu_irq irq)
ppc4xx_i2c_t *i2c;
int io;
- i2c = qemu_mallocz(sizeof(ppc4xx_i2c_t));
+ i2c = g_malloc0(sizeof(ppc4xx_i2c_t));
i2c->irq = irq;
#ifdef DEBUG_I2C
printf("%s: offset " TARGET_FMT_plx "\n", __func__, base);
@@ -1500,7 +1500,7 @@ static void ppc4xx_gpt_init(target_phys_addr_t base, qemu_irq irqs[5])
int i;
int io;
- gpt = qemu_mallocz(sizeof(ppc4xx_gpt_t));
+ gpt = g_malloc0(sizeof(ppc4xx_gpt_t));
for (i = 0; i < 5; i++) {
gpt->irqs[i] = irqs[i];
}
@@ -1731,7 +1731,7 @@ static void ppc405_mal_init(CPUState *env, qemu_irq irqs[4])
ppc40x_mal_t *mal;
int i;
- mal = qemu_mallocz(sizeof(ppc40x_mal_t));
+ mal = g_malloc0(sizeof(ppc40x_mal_t));
for (i = 0; i < 4; i++)
mal->irqs[i] = irqs[i];
qemu_register_reset(&ppc40x_mal_reset, mal);
@@ -2096,7 +2096,7 @@ static void ppc405cr_cpc_init (CPUState *env, clk_setup_t clk_setup[7],
{
ppc405cr_cpc_t *cpc;
- cpc = qemu_mallocz(sizeof(ppc405cr_cpc_t));
+ cpc = g_malloc0(sizeof(ppc405cr_cpc_t));
memcpy(cpc->clk_setup, clk_setup,
PPC405CR_CLK_NB * sizeof(clk_setup_t));
cpc->sysclk = sysclk;
@@ -2142,7 +2142,7 @@ CPUState *ppc405cr_init (target_phys_addr_t ram_bases[4],
/* OBP arbitrer */
ppc4xx_opba_init(0xef600600);
/* Universal interrupt controller */
- irqs = qemu_mallocz(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
+ irqs = g_malloc0(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
irqs[PPCUIC_OUTPUT_INT] =
((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
irqs[PPCUIC_OUTPUT_CINT] =
@@ -2433,7 +2433,7 @@ static void ppc405ep_cpc_init (CPUState *env, clk_setup_t clk_setup[8],
{
ppc405ep_cpc_t *cpc;
- cpc = qemu_mallocz(sizeof(ppc405ep_cpc_t));
+ cpc = g_malloc0(sizeof(ppc405ep_cpc_t));
memcpy(cpc->clk_setup, clk_setup,
PPC405EP_CLK_NB * sizeof(clk_setup_t));
cpc->jtagid = 0x20267049;
@@ -2490,7 +2490,7 @@ CPUState *ppc405ep_init (target_phys_addr_t ram_bases[2],
/* OBP arbitrer */
ppc4xx_opba_init(0xef600600);
/* Universal interrupt controller */
- irqs = qemu_mallocz(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
+ irqs = g_malloc0(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
irqs[PPCUIC_OUTPUT_INT] =
((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
irqs[PPCUIC_OUTPUT_CINT] =
diff --git a/hw/ppc440.c b/hw/ppc440.c
index 90abc9192..baf991f2d 100644
--- a/hw/ppc440.c
+++ b/hw/ppc440.c
@@ -57,7 +57,7 @@ CPUState *ppc440ep_init(ram_addr_t *ram_size, PCIBus **pcip,
ppc_dcr_init(env, NULL, NULL);
/* interrupt controller */
- irqs = qemu_mallocz(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
+ irqs = g_malloc0(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
irqs[PPCUIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
irqs[PPCUIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];
pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);
@@ -73,7 +73,7 @@ CPUState *ppc440ep_init(ram_addr_t *ram_size, PCIBus **pcip,
ram_sizes, do_init);
/* PCI */
- pci_irqs = qemu_malloc(sizeof(qemu_irq) * 4);
+ pci_irqs = g_malloc(sizeof(qemu_irq) * 4);
pci_irqs[0] = pic[pci_irq_nrs[0]];
pci_irqs[1] = pic[pci_irq_nrs[1]];
pci_irqs[2] = pic[pci_irq_nrs[2]];
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index 20b862939..1addb6832 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -49,7 +49,7 @@ static int bamboo_load_device_tree(target_phys_addr_t addr,
goto out;
}
fdt = load_device_tree(filename, &fdt_size);
- qemu_free(filename);
+ g_free(filename);
if (fdt == NULL) {
goto out;
}
@@ -80,7 +80,7 @@ static int bamboo_load_device_tree(target_phys_addr_t addr,
kvmppc_fdt_update(fdt);
ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
- qemu_free(fdt);
+ g_free(fdt);
out:
#endif
diff --git a/hw/ppc4xx_devs.c b/hw/ppc4xx_devs.c
index 68bdfaacc..1af5f2e79 100644
--- a/hw/ppc4xx_devs.c
+++ b/hw/ppc4xx_devs.c
@@ -293,7 +293,7 @@ qemu_irq *ppcuic_init (CPUState *env, qemu_irq *irqs,
ppcuic_t *uic;
int i;
- uic = qemu_mallocz(sizeof(ppcuic_t));
+ uic = g_malloc0(sizeof(ppcuic_t));
uic->dcr_base = dcr_base;
uic->irqs = irqs;
if (has_vr)
@@ -627,7 +627,7 @@ void ppc4xx_sdram_init (CPUState *env, qemu_irq irq, int nbanks,
{
ppc4xx_sdram_t *sdram;
- sdram = qemu_mallocz(sizeof(ppc4xx_sdram_t));
+ sdram = g_malloc0(sizeof(ppc4xx_sdram_t));
sdram->irq = irq;
sdram->nbanks = nbanks;
memset(sdram->ram_bases, 0, 4 * sizeof(target_phys_addr_t));
diff --git a/hw/ppc4xx_pci.c b/hw/ppc4xx_pci.c
index c7696b07d..52e2663a0 100644
--- a/hw/ppc4xx_pci.c
+++ b/hw/ppc4xx_pci.c
@@ -341,7 +341,7 @@ PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],
static int ppc4xx_pci_id;
uint8_t *pci_conf;
- controller = qemu_mallocz(sizeof(PPC4xxPCIState));
+ controller = g_malloc0(sizeof(PPC4xxPCIState));
controller->pci_state.bus = pci_register_bus(NULL, "pci",
ppc4xx_pci_set_irq,
@@ -390,6 +390,6 @@ PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],
free:
printf("%s error\n", __func__);
- qemu_free(controller);
+ g_free(controller);
return NULL;
}
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index 303902290..4727e0790 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -189,7 +189,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
bios_size = load_elf(filename, NULL, NULL, NULL,
NULL, NULL, 1, ELF_MACHINE, 0);
- qemu_free(filename);
+ g_free(filename);
} else {
bios_size = -1;
}
@@ -271,9 +271,9 @@ static void ppc_core99_init (ram_addr_t ram_size,
DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory);
- openpic_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
+ openpic_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
openpic_irqs[0] =
- qemu_mallocz(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
+ g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
for (i = 0; i < smp_cpus; i++) {
/* Mac99 IRQ connection between OpenPIC outputs pins
* and PowerPC input pins
@@ -398,7 +398,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
uint8_t *hypercall;
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
- hypercall = qemu_malloc(16);
+ hypercall = g_malloc(16);
kvmppc_get_hypercall(env, hypercall, 16);
fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 41703a7e2..0071fc950 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -127,7 +127,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
if (filename) {
bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL,
1, ELF_MACHINE, 0);
- qemu_free(filename);
+ g_free(filename);
} else {
bios_size = -1;
}
@@ -213,9 +213,9 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
isa_mmio_init(0xfe000000, 0x00200000);
/* XXX: we register only 1 output pin for heathrow PIC */
- heathrow_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
+ heathrow_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
heathrow_irqs[0] =
- qemu_mallocz(smp_cpus * sizeof(qemu_irq) * 1);
+ g_malloc0(smp_cpus * sizeof(qemu_irq) * 1);
/* Connect the heathrow PIC outputs to the 6xx bus */
for (i = 0; i < smp_cpus; i++) {
switch (PPC_INPUT(env)) {
@@ -306,7 +306,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
uint8_t *hypercall;
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
- hypercall = qemu_malloc(16);
+ hypercall = g_malloc(16);
kvmppc_get_hypercall(env, hypercall, 16);
fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 38d8573d1..515de42da 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -550,7 +550,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
- sysctrl = qemu_mallocz(sizeof(sysctrl_t));
+ sysctrl = g_malloc0(sizeof(sysctrl_t));
linux_boot = (kernel_filename != NULL);
@@ -599,7 +599,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
hw_error("qemu: could not load PPC PREP bios '%s'\n", bios_name);
}
if (filename) {
- qemu_free(filename);
+ g_free(filename);
}
if (linux_boot) {
@@ -673,7 +673,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
nb_nics1 = NE2000_NB_MAX;
for(i = 0; i < nb_nics1; i++) {
if (nd_table[i].model == NULL) {
- nd_table[i].model = qemu_strdup("ne2k_isa");
+ nd_table[i].model = g_strdup("ne2k_isa");
}
if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]);
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index b739ce27e..1274a3e1e 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -102,7 +102,7 @@ static int mpc8544_load_device_tree(CPUState *env,
goto out;
}
fdt = load_device_tree(filename, &fdt_size);
- qemu_free(filename);
+ g_free(filename);
if (fdt == NULL) {
goto out;
}
@@ -176,7 +176,7 @@ static int mpc8544_load_device_tree(CPUState *env,
}
ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
- qemu_free(fdt);
+ g_free(fdt);
out:
#endif
@@ -267,7 +267,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
"mpc8544ds.ram", ram_size));
/* MPIC */
- irqs = qemu_mallocz(sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
+ irqs = g_malloc0(sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
irqs[OPENPIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPCE500_INPUT_INT];
irqs[OPENPIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPCE500_INPUT_CINT];
mpic = mpic_init(MPC8544_MPIC_REGS_BASE, 1, &irqs, NULL);
@@ -336,7 +336,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
}
}
- boot_info = qemu_mallocz(sizeof(struct boot_info));
+ boot_info = g_malloc0(sizeof(struct boot_info));
/* If we're loading a kernel directly, we must load the device tree too. */
if (kernel_filename) {
diff --git a/hw/prep_pci.c b/hw/prep_pci.c
index 58619ddf7..c36232a80 100644
--- a/hw/prep_pci.c
+++ b/hw/prep_pci.c
@@ -118,7 +118,7 @@ PCIBus *pci_prep_init(qemu_irq *pic,
PCIDevice *d;
int PPC_io_memory;
- s = qemu_mallocz(sizeof(PREPPCIState));
+ s = g_malloc0(sizeof(PREPPCIState));
s->bus = pci_register_bus(NULL, "pci",
prep_set_irq, prep_map_irq, pic,
address_space_mem,
diff --git a/hw/ps2.c b/hw/ps2.c
index 91b73e08a..24228c153 100644
--- a/hw/ps2.c
+++ b/hw/ps2.c
@@ -604,7 +604,7 @@ static const VMStateDescription vmstate_ps2_mouse = {
void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg)
{
- PS2KbdState *s = (PS2KbdState *)qemu_mallocz(sizeof(PS2KbdState));
+ PS2KbdState *s = (PS2KbdState *)g_malloc0(sizeof(PS2KbdState));
s->common.update_irq = update_irq;
s->common.update_arg = update_arg;
@@ -617,7 +617,7 @@ void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg)
void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg)
{
- PS2MouseState *s = (PS2MouseState *)qemu_mallocz(sizeof(PS2MouseState));
+ PS2MouseState *s = (PS2MouseState *)g_malloc0(sizeof(PS2MouseState));
s->common.update_irq = update_irq;
s->common.update_arg = update_arg;
diff --git a/hw/ptimer.c b/hw/ptimer.c
index 6f13ce92f..b6cabd5b7 100644
--- a/hw/ptimer.c
+++ b/hw/ptimer.c
@@ -210,7 +210,7 @@ ptimer_state *ptimer_init(QEMUBH *bh)
{
ptimer_state *s;
- s = (ptimer_state *)qemu_mallocz(sizeof(ptimer_state));
+ s = (ptimer_state *)g_malloc0(sizeof(ptimer_state));
s->bh = bh;
s->timer = qemu_new_timer_ns(vm_clock, ptimer_tick, s);
return s;
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index cf9311014..d00edc617 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -1764,7 +1764,7 @@ static PXA2xxI2SState *pxa2xx_i2s_init(target_phys_addr_t base,
{
int iomemtype;
PXA2xxI2SState *s = (PXA2xxI2SState *)
- qemu_mallocz(sizeof(PXA2xxI2SState));
+ g_malloc0(sizeof(PXA2xxI2SState));
s->irq = irq;
s->rx_dma = rx_dma;
@@ -2025,7 +2025,7 @@ static PXA2xxFIrState *pxa2xx_fir_init(target_phys_addr_t base,
{
int iomemtype;
PXA2xxFIrState *s = (PXA2xxFIrState *)
- qemu_mallocz(sizeof(PXA2xxFIrState));
+ g_malloc0(sizeof(PXA2xxFIrState));
s->irq = irq;
s->rx_dma = rx_dma;
@@ -2064,7 +2064,7 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision)
PXA2xxState *s;
int iomemtype, i;
DriveInfo *dinfo;
- s = (PXA2xxState *) qemu_mallocz(sizeof(PXA2xxState));
+ s = (PXA2xxState *) g_malloc0(sizeof(PXA2xxState));
if (revision && strncmp(revision, "pxa27", 5)) {
fprintf(stderr, "Machine requires a PXA27x processor.\n");
@@ -2162,7 +2162,7 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision)
vmstate_register(NULL, 0, &vmstate_pxa2xx_pm, s);
for (i = 0; pxa27x_ssp[i].io_base; i ++);
- s->ssp = (SSIBus **)qemu_mallocz(sizeof(SSIBus *) * i);
+ s->ssp = (SSIBus **)g_malloc0(sizeof(SSIBus *) * i);
for (i = 0; pxa27x_ssp[i].io_base; i ++) {
DeviceState *dev;
dev = sysbus_create_simple("pxa2xx-ssp", pxa27x_ssp[i].io_base,
@@ -2207,7 +2207,7 @@ PXA2xxState *pxa255_init(unsigned int sdram_size)
int iomemtype, i;
DriveInfo *dinfo;
- s = (PXA2xxState *) qemu_mallocz(sizeof(PXA2xxState));
+ s = (PXA2xxState *) g_malloc0(sizeof(PXA2xxState));
s->env = cpu_init("pxa255");
if (!s->env) {
@@ -2298,7 +2298,7 @@ PXA2xxState *pxa255_init(unsigned int sdram_size)
vmstate_register(NULL, 0, &vmstate_pxa2xx_pm, s);
for (i = 0; pxa255_ssp[i].io_base; i ++);
- s->ssp = (SSIBus **)qemu_mallocz(sizeof(SSIBus *) * i);
+ s->ssp = (SSIBus **)g_malloc0(sizeof(SSIBus *) * i);
for (i = 0; pxa255_ssp[i].io_base; i ++) {
DeviceState *dev;
dev = sysbus_create_simple("pxa2xx-ssp", pxa255_ssp[i].io_base,
diff --git a/hw/pxa2xx_dma.c b/hw/pxa2xx_dma.c
index 599581e26..07ec2dbb6 100644
--- a/hw/pxa2xx_dma.c
+++ b/hw/pxa2xx_dma.c
@@ -461,7 +461,7 @@ static int pxa2xx_dma_init(SysBusDevice *dev)
return -1;
}
- s->chan = qemu_mallocz(sizeof(PXA2xxDMAChannel) * s->channels);
+ s->chan = g_malloc0(sizeof(PXA2xxDMAChannel) * s->channels);
memset(s->chan, 0, sizeof(PXA2xxDMAChannel) * s->channels);
for (i = 0; i < s->channels; i ++)
diff --git a/hw/pxa2xx_keypad.c b/hw/pxa2xx_keypad.c
index 10ef154aa..e33959d25 100644
--- a/hw/pxa2xx_keypad.c
+++ b/hw/pxa2xx_keypad.c
@@ -312,7 +312,7 @@ PXA2xxKeyPadState *pxa27x_keypad_init(target_phys_addr_t base,
int iomemtype;
PXA2xxKeyPadState *s;
- s = (PXA2xxKeyPadState *) qemu_mallocz(sizeof(PXA2xxKeyPadState));
+ s = (PXA2xxKeyPadState *) g_malloc0(sizeof(PXA2xxKeyPadState));
s->irq = irq;
iomemtype = cpu_register_io_memory(pxa2xx_keypad_readfn,
diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c
index a5f8c5116..97f90153b 100644
--- a/hw/pxa2xx_lcd.c
+++ b/hw/pxa2xx_lcd.c
@@ -986,7 +986,7 @@ PXA2xxLCDState *pxa2xx_lcdc_init(target_phys_addr_t base, qemu_irq irq)
int iomemtype;
PXA2xxLCDState *s;
- s = (PXA2xxLCDState *) qemu_mallocz(sizeof(PXA2xxLCDState));
+ s = (PXA2xxLCDState *) g_malloc0(sizeof(PXA2xxLCDState));
s->invalidated = 1;
s->irq = irq;
diff --git a/hw/pxa2xx_mmci.c b/hw/pxa2xx_mmci.c
index d86f735a2..1de497929 100644
--- a/hw/pxa2xx_mmci.c
+++ b/hw/pxa2xx_mmci.c
@@ -524,7 +524,7 @@ PXA2xxMMCIState *pxa2xx_mmci_init(target_phys_addr_t base,
int iomemtype;
PXA2xxMMCIState *s;
- s = (PXA2xxMMCIState *) qemu_mallocz(sizeof(PXA2xxMMCIState));
+ s = (PXA2xxMMCIState *) g_malloc0(sizeof(PXA2xxMMCIState));
s->irq = irq;
s->rx_dma = rx_dma;
s->tx_dma = tx_dma;
diff --git a/hw/pxa2xx_pcmcia.c b/hw/pxa2xx_pcmcia.c
index 50d4649f6..74c6817ba 100644
--- a/hw/pxa2xx_pcmcia.c
+++ b/hw/pxa2xx_pcmcia.c
@@ -136,7 +136,7 @@ PXA2xxPCMCIAState *pxa2xx_pcmcia_init(target_phys_addr_t base)
PXA2xxPCMCIAState *s;
s = (PXA2xxPCMCIAState *)
- qemu_mallocz(sizeof(PXA2xxPCMCIAState));
+ g_malloc0(sizeof(PXA2xxPCMCIAState));
/* Socket I/O Memory Space */
iomemtype = cpu_register_io_memory(pxa2xx_pcmcia_io_readfn,
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index eff2d2494..0c0c29212 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -275,14 +275,14 @@ static int parse_string(DeviceState *dev, Property *prop, const char *str)
char **ptr = qdev_get_prop_ptr(dev, prop);
if (*ptr)
- qemu_free(*ptr);
- *ptr = qemu_strdup(str);
+ g_free(*ptr);
+ *ptr = g_strdup(str);
return 0;
}
static void free_string(DeviceState *dev, Property *prop)
{
- qemu_free(*(char **)qdev_get_prop_ptr(dev, prop));
+ g_free(*(char **)qdev_get_prop_ptr(dev, prop));
}
static int print_string(DeviceState *dev, Property *prop, char *dest, size_t len)
@@ -768,7 +768,7 @@ static int qdev_add_one_global(QemuOpts *opts, void *opaque)
{
GlobalProperty *g;
- g = qemu_mallocz(sizeof(*g));
+ g = g_malloc0(sizeof(*g));
g->driver = qemu_opt_get(opts, "driver");
g->property = qemu_opt_get(opts, "property");
g->value = qemu_opt_get(opts, "value");
diff --git a/hw/qdev.c b/hw/qdev.c
index d8114c6d9..c463c5215 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -85,7 +85,7 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info)
DeviceState *dev;
assert(bus->info == info->bus_info);
- dev = qemu_mallocz(info->size);
+ dev = g_malloc0(info->size);
dev->info = info;
dev->parent_bus = bus;
qdev_prop_set_defaults(dev, dev->info->props);
@@ -408,7 +408,7 @@ void qdev_free(DeviceState *dev)
prop->info->free(dev, prop);
}
}
- qemu_free(dev);
+ g_free(dev);
}
void qdev_machine_creation_done(void)
@@ -750,17 +750,17 @@ void qbus_create_inplace(BusState *bus, BusInfo *info,
if (name) {
/* use supplied name */
- bus->name = qemu_strdup(name);
+ bus->name = g_strdup(name);
} else if (parent && parent->id) {
/* parent device has id -> use it for bus name */
len = strlen(parent->id) + 16;
- buf = qemu_malloc(len);
+ buf = g_malloc(len);
snprintf(buf, len, "%s.%d", parent->id, parent->num_child_bus);
bus->name = buf;
} else {
/* no id -> use lowercase bus type for bus name */
len = strlen(info->name) + 16;
- buf = qemu_malloc(len);
+ buf = g_malloc(len);
len = snprintf(buf, len, "%s.%d", info->name,
parent ? parent->num_child_bus : 0);
for (i = 0; i < len; i++)
@@ -783,7 +783,7 @@ BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name)
{
BusState *bus;
- bus = qemu_mallocz(info->size);
+ bus = g_malloc0(info->size);
bus->qdev_allocated = 1;
qbus_create_inplace(bus, info, parent, name);
return bus;
@@ -793,7 +793,7 @@ static void main_system_bus_create(void)
{
/* assign main_system_bus before qbus_create_inplace()
* in order to make "if (bus != main_system_bus)" work */
- main_system_bus = qemu_mallocz(system_bus_info.size);
+ main_system_bus = g_malloc0(system_bus_info.size);
main_system_bus->qdev_allocated = 1;
qbus_create_inplace(main_system_bus, &system_bus_info, NULL,
"main-system-bus");
@@ -813,9 +813,9 @@ void qbus_free(BusState *bus)
assert(bus != main_system_bus); /* main_system_bus is never freed */
qemu_unregister_reset(qbus_reset_all_fn, bus);
}
- qemu_free((void*)bus->name);
+ g_free((void*)bus->name);
if (bus->qdev_allocated) {
- qemu_free(bus);
+ g_free(bus);
}
}
@@ -935,7 +935,7 @@ static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
if (dev->parent_bus->info->get_fw_dev_path) {
d = dev->parent_bus->info->get_fw_dev_path(dev);
l += snprintf(p + l, size - l, "%s", d);
- qemu_free(d);
+ g_free(d);
} else {
l += snprintf(p + l, size - l, "%s", dev->info->name);
}
diff --git a/hw/qxl-render.c b/hw/qxl-render.c
index 1b775770c..c290739de 100644
--- a/hw/qxl-render.c
+++ b/hw/qxl-render.c
@@ -81,7 +81,7 @@ void qxl_render_update(PCIQXLDevice *qxl)
qxl->guest_primary.resized = 0;
if (qxl->guest_primary.flipped) {
- qemu_free(qxl->guest_primary.flipped);
+ g_free(qxl->guest_primary.flipped);
qxl->guest_primary.flipped = NULL;
}
qemu_free_displaysurface(vga->ds);
@@ -90,7 +90,7 @@ void qxl_render_update(PCIQXLDevice *qxl)
if (qxl->guest_primary.stride < 0) {
/* spice surface is upside down -> need extra buffer to flip */
qxl->guest_primary.stride = -qxl->guest_primary.stride;
- qxl->guest_primary.flipped = qemu_malloc(qxl->guest_primary.surface.width *
+ qxl->guest_primary.flipped = g_malloc(qxl->guest_primary.surface.width *
qxl->guest_primary.stride);
ptr = qxl->guest_primary.flipped;
} else {
diff --git a/hw/qxl.c b/hw/qxl.c
index b34bccf62..bab60a526 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1697,7 +1697,7 @@ static int qxl_post_load(void *opaque, int version)
qxl_create_guest_primary(d, 1, QXL_SYNC);
/* replay surface-create and cursor-set commands */
- cmds = qemu_mallocz(sizeof(QXLCommandExt) * (NUM_SURFACES + 1));
+ cmds = g_malloc0(sizeof(QXLCommandExt) * (NUM_SURFACES + 1));
for (in = 0, out = 0; in < NUM_SURFACES; in++) {
if (d->guest_surfaces.cmds[in] == 0) {
continue;
@@ -1712,7 +1712,7 @@ static int qxl_post_load(void *opaque, int version)
cmds[out].group_id = MEMSLOT_GROUP_GUEST;
out++;
qxl_spice_loadvm_commands(d, cmds, out);
- qemu_free(cmds);
+ g_free(cmds);
break;
case QXL_MODE_COMPAT:
diff --git a/hw/r2d.c b/hw/r2d.c
index a0f8c1f20..96a7ff8c3 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -184,7 +184,7 @@ static qemu_irq *r2d_fpga_init(target_phys_addr_t base, qemu_irq irl)
int iomemtype;
r2d_fpga_t *s;
- s = qemu_mallocz(sizeof(r2d_fpga_t));
+ s = g_malloc0(sizeof(r2d_fpga_t));
s->irl = irl;
@@ -244,7 +244,7 @@ static void r2d_init(ram_addr_t ram_size,
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
- reset_info = qemu_mallocz(sizeof(ResetData));
+ reset_info = g_malloc0(sizeof(ResetData));
reset_info->env = env;
reset_info->vector = env->pc;
qemu_register_reset(main_cpu_reset, reset_info);
diff --git a/hw/rc4030.c b/hw/rc4030.c
index 6563336dd..a2a20996a 100644
--- a/hw/rc4030.c
+++ b/hw/rc4030.c
@@ -789,8 +789,8 @@ static rc4030_dma *rc4030_allocate_dmas(void *opaque, int n)
struct rc4030DMAState *p;
int i;
- s = (rc4030_dma *)qemu_mallocz(sizeof(rc4030_dma) * n);
- p = (struct rc4030DMAState *)qemu_mallocz(sizeof(struct rc4030DMAState) * n);
+ s = (rc4030_dma *)g_malloc0(sizeof(rc4030_dma) * n);
+ p = (struct rc4030DMAState *)g_malloc0(sizeof(struct rc4030DMAState) * n);
for (i = 0; i < n; i++) {
p->opaque = opaque;
p->n = i;
@@ -806,7 +806,7 @@ void *rc4030_init(qemu_irq timer, qemu_irq jazz_bus,
rc4030State *s;
int s_chipset, s_jazzio;
- s = qemu_mallocz(sizeof(rc4030State));
+ s = g_malloc0(sizeof(rc4030State));
*irqs = qemu_allocate_irqs(rc4030_irq_jazz_request, s, 16);
*dmas = rc4030_allocate_dmas(s, 4);
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index c6cafc251..c5de5b48b 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -1796,7 +1796,7 @@ static void rtl8139_transfer_frame(RTL8139State *s, uint8_t *buf, int size,
if (iov) {
buf2_size = iov_size(iov, 3);
- buf2 = qemu_malloc(buf2_size);
+ buf2 = g_malloc(buf2_size);
iov_to_buf(iov, 3, buf2, 0, buf2_size);
buf = buf2;
}
@@ -1805,7 +1805,7 @@ static void rtl8139_transfer_frame(RTL8139State *s, uint8_t *buf, int size,
rtl8139_do_receive(&s->nic->nc, buf, size, do_interrupt);
if (iov) {
- qemu_free(buf2);
+ g_free(buf2);
}
}
else
@@ -2053,7 +2053,7 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
if (!s->cplus_txbuffer)
{
s->cplus_txbuffer_len = CP_TX_BUFFER_SIZE;
- s->cplus_txbuffer = qemu_malloc(s->cplus_txbuffer_len);
+ s->cplus_txbuffer = g_malloc(s->cplus_txbuffer_len);
s->cplus_txbuffer_offset = 0;
DPRINTF("+++ C+ mode transmission buffer allocated space %d\n",
@@ -2063,7 +2063,7 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
while (s->cplus_txbuffer && s->cplus_txbuffer_offset + txsize >= s->cplus_txbuffer_len)
{
s->cplus_txbuffer_len += CP_TX_BUFFER_SIZE;
- s->cplus_txbuffer = qemu_realloc(s->cplus_txbuffer, s->cplus_txbuffer_len);
+ s->cplus_txbuffer = g_realloc(s->cplus_txbuffer, s->cplus_txbuffer_len);
DPRINTF("+++ C+ mode transmission buffer space changed to %d\n",
s->cplus_txbuffer_len);
@@ -2401,7 +2401,7 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
}
else
{
- qemu_free(saved_buffer);
+ g_free(saved_buffer);
}
}
else
@@ -3441,7 +3441,7 @@ static int pci_rtl8139_uninit(PCIDevice *dev)
memory_region_destroy(&s->bar_io);
memory_region_destroy(&s->bar_mem);
if (s->cplus_txbuffer) {
- qemu_free(s->cplus_txbuffer);
+ g_free(s->cplus_txbuffer);
s->cplus_txbuffer = NULL;
}
qemu_del_timer(s->timer);
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index abe954dc8..acbf02604 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -165,14 +165,14 @@ static void s390_init(ram_addr_t my_ram_size,
cpu_register_physical_memory(0, my_ram_size, ram_addr);
/* allocate storage keys */
- storage_keys = qemu_mallocz(my_ram_size / TARGET_PAGE_SIZE);
+ storage_keys = g_malloc0(my_ram_size / TARGET_PAGE_SIZE);
/* init CPUs */
if (cpu_model == NULL) {
cpu_model = "host";
}
- ipi_states = qemu_malloc(sizeof(CPUState *) * smp_cpus);
+ ipi_states = g_malloc(sizeof(CPUState *) * smp_cpus);
for (i = 0; i < smp_cpus; i++) {
CPUState *tmp_env;
@@ -211,7 +211,7 @@ static void s390_init(ram_addr_t my_ram_size,
bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
bios_size = load_image(bios_filename, qemu_get_ram_ptr(ZIPL_LOAD_ADDR));
- qemu_free(bios_filename);
+ g_free(bios_filename);
if ((long)bios_size < 0) {
hw_error("could not load bootloader '%s'\n", bios_name);
@@ -247,7 +247,7 @@ static void s390_init(ram_addr_t my_ram_size,
DeviceState *dev;
if (!nd->model) {
- nd->model = qemu_strdup("virtio");
+ nd->model = g_strdup("virtio");
}
if (strcmp(nd->model, "virtio")) {
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index c3ce7df6a..6f0d03958 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -346,7 +346,7 @@ SCSIRequest *scsi_req_alloc(SCSIReqOps *reqops, SCSIDevice *d, uint32_t tag,
{
SCSIRequest *req;
- req = qemu_mallocz(reqops->size);
+ req = g_malloc0(reqops->size);
req->refcount = 1;
req->bus = scsi_bus_from_device(d);
req->dev = d;
@@ -1015,7 +1015,7 @@ void scsi_req_unref(SCSIRequest *req)
if (req->ops->free_req) {
req->ops->free_req(req);
}
- qemu_free(req);
+ g_free(req);
}
}
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index f1ffe9594..d94b1eb53 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1125,12 +1125,12 @@ static int scsi_initfn(SCSIDevice *dev, uint8_t scsi_type)
/* try to fall back to value set with legacy -drive serial=... */
dinfo = drive_get_by_blockdev(s->bs);
if (*dinfo->serial) {
- s->serial = qemu_strdup(dinfo->serial);
+ s->serial = g_strdup(dinfo->serial);
}
}
if (!s->version) {
- s->version = qemu_strdup(QEMU_VERSION);
+ s->version = g_strdup(QEMU_VERSION);
}
if (bdrv_is_sg(s->bs)) {
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index b63371e65..cb5d4f125 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -66,7 +66,7 @@ static void scsi_free_request(SCSIRequest *req)
{
SCSIGenericReq *r = DO_UPCAST(SCSIGenericReq, req, req);
- qemu_free(r->buf);
+ g_free(r->buf);
}
/* Helper function for command completion. */
@@ -288,7 +288,7 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *cmd)
if (r->req.cmd.xfer == 0) {
if (r->buf != NULL)
- qemu_free(r->buf);
+ g_free(r->buf);
r->buflen = 0;
r->buf = NULL;
ret = execute_command(s->bs, r, SG_DXFER_NONE, scsi_command_complete);
@@ -301,8 +301,8 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *cmd)
if (r->buflen != r->req.cmd.xfer) {
if (r->buf != NULL)
- qemu_free(r->buf);
- r->buf = qemu_malloc(r->req.cmd.xfer);
+ g_free(r->buf);
+ r->buf = g_malloc(r->req.cmd.xfer);
r->buflen = r->req.cmd.xfer;
}
diff --git a/hw/sd.c b/hw/sd.c
index c2c80ab7b..bb8c2ff67 100644
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -409,9 +409,9 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv)
sd->bdrv = bdrv;
if (sd->wp_groups)
- qemu_free(sd->wp_groups);
+ g_free(sd->wp_groups);
sd->wp_switch = bdrv ? bdrv_is_read_only(bdrv) : 0;
- sd->wp_groups = (int *) qemu_mallocz(sizeof(int) * sect);
+ sd->wp_groups = (int *) g_malloc0(sizeof(int) * sect);
memset(sd->function_group, 0, sizeof(int) * 6);
sd->erase_start = 0;
sd->erase_end = 0;
@@ -443,7 +443,7 @@ SDState *sd_init(BlockDriverState *bs, int is_spi)
{
SDState *sd;
- sd = (SDState *) qemu_mallocz(sizeof(SDState));
+ sd = (SDState *) g_malloc0(sizeof(SDState));
sd->buf = qemu_blockalign(bs, 512);
sd->spi = is_spi;
sd->enable = 1;
diff --git a/hw/serial.c b/hw/serial.c
index 0ee61ddce..222e356be 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -797,7 +797,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase,
{
SerialState *s;
- s = qemu_mallocz(sizeof(SerialState));
+ s = g_malloc0(sizeof(SerialState));
s->irq = irq;
s->baudbase = baudbase;
@@ -931,7 +931,7 @@ SerialState *serial_mm_init (target_phys_addr_t base, int it_shift,
SerialState *s;
int s_io_memory;
- s = qemu_mallocz(sizeof(SerialState));
+ s = g_malloc0(sizeof(SerialState));
s->it_shift = it_shift;
s->irq = irq;
diff --git a/hw/sh7750.c b/hw/sh7750.c
index 4f279e7e5..9f3ea9285 100644
--- a/hw/sh7750.c
+++ b/hw/sh7750.c
@@ -712,7 +712,7 @@ SH7750State *sh7750_init(CPUSH4State * cpu)
int sh7750_io_memory;
int sh7750_mm_cache_and_tlb; /* memory mapped cache and tlb */
- s = qemu_mallocz(sizeof(SH7750State));
+ s = g_malloc0(sizeof(SH7750State));
s->cpu = cpu;
s->periph_freq = 60000000; /* 60MHz */
sh7750_io_memory = cpu_register_io_memory(sh7750_mem_read,
diff --git a/hw/sh_intc.c b/hw/sh_intc.c
index c43b99f81..ecb46e585 100644
--- a/hw/sh_intc.c
+++ b/hw/sh_intc.c
@@ -431,7 +431,7 @@ int sh_intc_init(struct intc_desc *desc,
desc->nr_prio_regs = nr_prio_regs;
i = sizeof(struct intc_source) * nr_sources;
- desc->sources = qemu_mallocz(i);
+ desc->sources = g_malloc0(i);
for (i = 0; i < desc->nr_sources; i++) {
struct intc_source *source = desc->sources + i;
diff --git a/hw/sh_serial.c b/hw/sh_serial.c
index 191f4a60c..1767c97fc 100644
--- a/hw/sh_serial.c
+++ b/hw/sh_serial.c
@@ -361,7 +361,7 @@ void sh_serial_init (target_phys_addr_t base, int feat,
sh_serial_state *s;
int s_io_memory;
- s = qemu_mallocz(sizeof(sh_serial_state));
+ s = g_malloc0(sizeof(sh_serial_state));
s->feat = feat;
s->flags = SH_SERIAL_FLAG_TEND | SH_SERIAL_FLAG_TDE;
diff --git a/hw/sh_timer.c b/hw/sh_timer.c
index 5df7fb64b..dca3c9421 100644
--- a/hw/sh_timer.c
+++ b/hw/sh_timer.c
@@ -188,7 +188,7 @@ static void *sh_timer_init(uint32_t freq, int feat, qemu_irq irq)
sh_timer_state *s;
QEMUBH *bh;
- s = (sh_timer_state *)qemu_mallocz(sizeof(sh_timer_state));
+ s = (sh_timer_state *)g_malloc0(sizeof(sh_timer_state));
s->freq = freq;
s->feat = feat;
s->tcor = 0xffffffff;
@@ -311,7 +311,7 @@ void tmu012_init(target_phys_addr_t base, int feat, uint32_t freq,
tmu012_state *s;
int timer_feat = (feat & TMU012_FEAT_EXTCLK) ? TIMER_FEAT_EXTCLK : 0;
- s = (tmu012_state *)qemu_mallocz(sizeof(tmu012_state));
+ s = (tmu012_state *)g_malloc0(sizeof(tmu012_state));
s->feat = feat;
s->timer[0] = sh_timer_init(freq, timer_feat, ch0_irq);
s->timer[1] = sh_timer_init(freq, timer_feat, ch1_irq);
diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c
index 551131368..f89b4fb5b 100644
--- a/hw/slavio_timer.c
+++ b/hw/slavio_timer.c
@@ -381,7 +381,7 @@ static int slavio_timer_init1(SysBusDevice *dev)
TimerContext *tc;
for (i = 0; i <= MAX_CPUS; i++) {
- tc = qemu_mallocz(sizeof(TimerContext));
+ tc = g_malloc0(sizeof(TimerContext));
tc->s = s;
tc->timer_index = i;
diff --git a/hw/sm501.c b/hw/sm501.c
index 0f0bf9660..1ed0a7e30 100644
--- a/hw/sm501.c
+++ b/hw/sm501.c
@@ -1395,7 +1395,7 @@ void sm501_init(uint32_t base, uint32_t local_mem_bytes, qemu_irq irq,
int sm501_2d_engine_index;
/* allocate management data region */
- s = (SM501State *)qemu_mallocz(sizeof(SM501State));
+ s = (SM501State *)g_malloc0(sizeof(SM501State));
s->base = base;
s->local_mem_size_index
= get_local_mem_size_index(local_mem_bytes);
diff --git a/hw/smbios.c b/hw/smbios.c
index a3ae1de82..8f2e96538 100644
--- a/hw/smbios.c
+++ b/hw/smbios.c
@@ -105,9 +105,9 @@ void smbios_add_field(int type, int offset, int len, void *data)
if (!smbios_entries) {
smbios_entries_len = sizeof(uint16_t);
- smbios_entries = qemu_mallocz(smbios_entries_len);
+ smbios_entries = g_malloc0(smbios_entries_len);
}
- smbios_entries = qemu_realloc(smbios_entries, smbios_entries_len +
+ smbios_entries = g_realloc(smbios_entries, smbios_entries_len +
sizeof(*field) + len);
field = (struct smbios_field *)(smbios_entries + smbios_entries_len);
field->header.type = SMBIOS_FIELD_ENTRY;
@@ -192,10 +192,10 @@ int smbios_entry_add(const char *t)
if (!smbios_entries) {
smbios_entries_len = sizeof(uint16_t);
- smbios_entries = qemu_mallocz(smbios_entries_len);
+ smbios_entries = g_malloc0(smbios_entries_len);
}
- smbios_entries = qemu_realloc(smbios_entries, smbios_entries_len +
+ smbios_entries = g_realloc(smbios_entries, smbios_entries_len +
sizeof(*table) + size);
table = (struct smbios_table *)(smbios_entries + smbios_entries_len);
table->header.type = SMBIOS_TABLE_ENTRY;
diff --git a/hw/smbus_eeprom.c b/hw/smbus_eeprom.c
index 363475489..5d080abed 100644
--- a/hw/smbus_eeprom.c
+++ b/hw/smbus_eeprom.c
@@ -130,7 +130,7 @@ void smbus_eeprom_init(i2c_bus *smbus, int nb_eeprom,
const uint8_t *eeprom_spd, int eeprom_spd_size)
{
int i;
- uint8_t *eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */
+ uint8_t *eeprom_buf = g_malloc0(8 * 256); /* XXX: make this persistent */
if (eeprom_spd_size > 0) {
memcpy(eeprom_buf, eeprom_spd, eeprom_spd_size);
}
diff --git a/hw/soc_dma.c b/hw/soc_dma.c
index 3f0f41410..03bc8468d 100644
--- a/hw/soc_dma.c
+++ b/hw/soc_dma.c
@@ -48,7 +48,7 @@ static int fifo_size;
static void transfer_fifo2fifo(struct soc_dma_ch_s *ch)
{
if (ch->bytes > fifo_size)
- fifo_buf = qemu_realloc(fifo_buf, fifo_size = ch->bytes);
+ fifo_buf = g_realloc(fifo_buf, fifo_size = ch->bytes);
/* Implement as transfer_fifo2linear + transfer_linear2fifo. */
ch->io_fn[0](ch->io_opaque[0], fifo_buf, ch->bytes);
@@ -239,7 +239,7 @@ void soc_dma_reset(struct soc_dma_s *soc)
struct soc_dma_s *soc_dma_init(int n)
{
int i;
- struct dma_s *s = qemu_mallocz(sizeof(*s) + n * sizeof(*s->ch));
+ struct dma_s *s = g_malloc0(sizeof(*s) + n * sizeof(*s->ch));
s->chnum = n;
s->soc.ch = s->ch;
@@ -261,7 +261,7 @@ void soc_dma_port_add_fifo(struct soc_dma_s *soc, target_phys_addr_t virt_base,
struct memmap_entry_s *entry;
struct dma_s *dma = (struct dma_s *) soc;
- dma->memmap = qemu_realloc(dma->memmap, sizeof(*entry) *
+ dma->memmap = g_realloc(dma->memmap, sizeof(*entry) *
(dma->memmap_size + 1));
entry = soc_dma_lookup(dma, virt_base);
@@ -313,7 +313,7 @@ void soc_dma_port_add_mem(struct soc_dma_s *soc, uint8_t *phys_base,
struct memmap_entry_s *entry;
struct dma_s *dma = (struct dma_s *) soc;
- dma->memmap = qemu_realloc(dma->memmap, sizeof(*entry) *
+ dma->memmap = g_realloc(dma->memmap, sizeof(*entry) *
(dma->memmap_size + 1));
entry = soc_dma_lookup(dma, virt_base);
diff --git a/hw/spapr.c b/hw/spapr.c
index 109b77459..1265cee6d 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -85,7 +85,7 @@ static void *spapr_create_fdt_skel(const char *cpu_model,
} \
} while (0)
- fdt = qemu_mallocz(FDT_MAX_SIZE);
+ fdt = g_malloc0(FDT_MAX_SIZE);
_FDT((fdt_create(fdt, FDT_MAX_SIZE)));
_FDT((fdt_finish_reservemap(fdt)));
@@ -125,7 +125,7 @@ static void *spapr_create_fdt_skel(const char *cpu_model,
_FDT((fdt_property_cell(fdt, "#address-cells", 0x1)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x0)));
- modelname = qemu_strdup(cpu_model);
+ modelname = g_strdup(cpu_model);
for (i = 0; i < strlen(modelname); i++) {
modelname[i] = toupper(modelname[i]);
@@ -176,7 +176,7 @@ static void *spapr_create_fdt_skel(const char *cpu_model,
_FDT((fdt_end_node(fdt)));
}
- qemu_free(modelname);
+ g_free(modelname);
_FDT((fdt_end_node(fdt)));
@@ -228,7 +228,7 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,
int ret;
void *fdt;
- fdt = qemu_malloc(FDT_MAX_SIZE);
+ fdt = g_malloc(FDT_MAX_SIZE);
/* open out the base tree into a temp buffer for the final tweaks */
_FDT((fdt_open_into(spapr->fdt_skel, fdt, FDT_MAX_SIZE)));
@@ -249,7 +249,7 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,
cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));
- qemu_free(fdt);
+ g_free(fdt);
}
static uint64_t translate_kernel_address(void *opaque, uint64_t addr)
@@ -300,7 +300,7 @@ static void ppc_spapr_init(ram_addr_t ram_size,
char *filename;
int irq = 16;
- spapr = qemu_malloc(sizeof(*spapr));
+ spapr = g_malloc(sizeof(*spapr));
cpu_ppc_hypercall = emulate_spapr_hypercall;
/* We place the device tree just below either the top of RAM, or
@@ -337,7 +337,7 @@ static void ppc_spapr_init(ram_addr_t ram_size,
* later we should probably make it scale to the size of guest
* RAM */
spapr->htab_size = 1ULL << (pteg_shift + 7);
- spapr->htab = qemu_malloc(spapr->htab_size);
+ spapr->htab = g_malloc(spapr->htab_size);
for (env = first_cpu; env != NULL; env = env->next_cpu) {
env->external_htab = spapr->htab;
@@ -352,7 +352,7 @@ static void ppc_spapr_init(ram_addr_t ram_size,
hw_error("qemu: could not load LPAR rtas '%s'\n", filename);
exit(1);
}
- qemu_free(filename);
+ g_free(filename);
/* Set up Interrupt Controller */
spapr->icp = xics_system_init(XICS_IRQS);
@@ -372,7 +372,7 @@ static void ppc_spapr_init(ram_addr_t ram_size,
NICInfo *nd = &nd_table[i];
if (!nd->model) {
- nd->model = qemu_strdup("ibmveth");
+ nd->model = g_strdup("ibmveth");
}
if (strcmp(nd->model, "ibmveth") == 0) {
@@ -436,7 +436,7 @@ static void ppc_spapr_init(ram_addr_t ram_size,
hw_error("qemu: could not load LPAR rtas '%s'\n", filename);
exit(1);
}
- qemu_free(filename);
+ g_free(filename);
spapr->entry_point = 0x100;
initrd_base = 0;
initrd_size = 0;
diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
index 481a804e7..ce6558bb7 100644
--- a/hw/spapr_vio.c
+++ b/hw/spapr_vio.c
@@ -160,7 +160,7 @@ static void rtce_init(VIOsPAPRDevice *dev)
* sizeof(VIOsPAPR_RTCE);
if (size) {
- dev->rtce_table = qemu_mallocz(size);
+ dev->rtce_table = g_malloc0(size);
}
}
diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c
index d98d1fd0b..fc9ac6ab5 100644
--- a/hw/spapr_vscsi.c
+++ b/hw/spapr_vscsi.c
@@ -788,7 +788,7 @@ static void vscsi_got_payload(VSCSIState *s, vscsi_crq *crq)
if (spapr_tce_dma_read(&s->vdev, crq->s.IU_data_ptr, &req->iu,
crq->s.IU_length)) {
fprintf(stderr, "vscsi_got_payload: DMA read failure !\n");
- qemu_free(req);
+ g_free(req);
}
memcpy(&req->crq, crq, sizeof(vscsi_crq));
diff --git a/hw/stellaris.c b/hw/stellaris.c
index a28093043..646eec74c 100644
--- a/hw/stellaris.c
+++ b/hw/stellaris.c
@@ -605,7 +605,7 @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq,
int iomemtype;
ssys_state *s;
- s = (ssys_state *)qemu_mallocz(sizeof(ssys_state));
+ s = (ssys_state *)g_malloc0(sizeof(ssys_state));
s->irq = irq;
s->board = board;
/* Most devices come preprogrammed with a MAC address in the user data. */
diff --git a/hw/stellaris_enet.c b/hw/stellaris_enet.c
index 12919317e..f9bd3da20 100644
--- a/hw/stellaris_enet.c
+++ b/hw/stellaris_enet.c
@@ -393,7 +393,7 @@ static void stellaris_enet_cleanup(VLANClientState *nc)
cpu_unregister_io_memory(s->mmio_index);
- qemu_free(s);
+ g_free(s);
}
static NetClientInfo net_stellaris_enet_info = {
diff --git a/hw/stellaris_input.c b/hw/stellaris_input.c
index 95604ecde..68c600c04 100644
--- a/hw/stellaris_input.c
+++ b/hw/stellaris_input.c
@@ -77,8 +77,8 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode)
gamepad_state *s;
int i;
- s = (gamepad_state *)qemu_mallocz(sizeof (gamepad_state));
- s->buttons = (gamepad_button *)qemu_mallocz(n * sizeof (gamepad_button));
+ s = (gamepad_state *)g_malloc0(sizeof (gamepad_state));
+ s->buttons = (gamepad_button *)g_malloc0(n * sizeof (gamepad_button));
for (i = 0; i < n; i++) {
s->buttons[i].irq = irq[i];
s->buttons[i].keycode = keycode[i];
diff --git a/hw/strongarm.c b/hw/strongarm.c
index 0e03d61a1..3a7fd6da8 100644
--- a/hw/strongarm.c
+++ b/hw/strongarm.c
@@ -1529,7 +1529,7 @@ StrongARMState *sa1110_init(unsigned int sdram_size, const char *rev)
qemu_irq *pic;
int i;
- s = qemu_mallocz(sizeof(StrongARMState));
+ s = g_malloc0(sizeof(StrongARMState));
if (!rev) {
rev = "sa1110-b5";
diff --git a/hw/sun4m.c b/hw/sun4m.c
index df3aa321c..7516703a5 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -681,7 +681,7 @@ static void prom_init(target_phys_addr_t addr, const char *bios_name)
if (ret < 0 || ret > PROM_SIZE_MAX) {
ret = load_image_targphys(filename, addr, PROM_SIZE_MAX);
}
- qemu_free(filename);
+ g_free(filename);
} else {
ret = -1;
}
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 7b2d0b17e..1b60e4ef5 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -351,7 +351,7 @@ static CPUTimer* cpu_timer_create(const char* name, CPUState *env,
QEMUBHFunc *cb, uint32_t frequency,
uint64_t disabled_mask)
{
- CPUTimer *timer = qemu_mallocz(sizeof (CPUTimer));
+ CPUTimer *timer = g_malloc0(sizeof (CPUTimer));
timer->name = name;
timer->frequency = frequency;
@@ -608,7 +608,7 @@ static void prom_init(target_phys_addr_t addr, const char *bios_name)
if (ret < 0 || ret > PROM_SIZE_MAX) {
ret = load_image_targphys(filename, addr, PROM_SIZE_MAX);
}
- qemu_free(filename);
+ g_free(filename);
} else {
ret = -1;
}
@@ -723,7 +723,7 @@ static CPUState *cpu_devinit(const char *cpu_model, const struct hwdef *hwdef)
env->hstick = cpu_timer_create("hstick", env, hstick_irq,
hstick_frequency, TICK_INT_DIS);
- reset_info = qemu_mallocz(sizeof(ResetData));
+ reset_info = g_malloc0(sizeof(ResetData));
reset_info->env = env;
reset_info->prom_addr = hwdef->prom_addr;
qemu_register_reset(main_cpu_reset, reset_info);
diff --git a/hw/syborg_interrupt.c b/hw/syborg_interrupt.c
index 5217983f6..1b0f3bb9b 100644
--- a/hw/syborg_interrupt.c
+++ b/hw/syborg_interrupt.c
@@ -213,7 +213,7 @@ static int syborg_int_init(SysBusDevice *dev)
syborg_int_writefn, s,
DEVICE_NATIVE_ENDIAN);
sysbus_init_mmio(dev, 0x1000, iomemtype);
- s->flags = qemu_mallocz(s->num_irqs * sizeof(syborg_int_flags));
+ s->flags = g_malloc0(s->num_irqs * sizeof(syborg_int_flags));
register_savevm(&dev->qdev, "syborg_int", -1, 1, syborg_int_save,
syborg_int_load, s);
diff --git a/hw/syborg_keyboard.c b/hw/syborg_keyboard.c
index 706a03966..82b9dc088 100644
--- a/hw/syborg_keyboard.c
+++ b/hw/syborg_keyboard.c
@@ -195,7 +195,7 @@ static int syborg_keyboard_init(SysBusDevice *dev)
fprintf(stderr, "syborg_keyboard: fifo too small\n");
s->fifo_size = 16;
}
- s->key_fifo = qemu_mallocz(s->fifo_size * sizeof(s->key_fifo[0]));
+ s->key_fifo = g_malloc0(s->fifo_size * sizeof(s->key_fifo[0]));
qemu_add_kbd_event_handler(syborg_keyboard_event, s);
diff --git a/hw/syborg_pointer.c b/hw/syborg_pointer.c
index 2f9970704..b91214dae 100644
--- a/hw/syborg_pointer.c
+++ b/hw/syborg_pointer.c
@@ -198,7 +198,7 @@ static int syborg_pointer_init(SysBusDevice *dev)
fprintf(stderr, "syborg_pointer: fifo too small\n");
s->fifo_size = 16;
}
- s->event_fifo = qemu_mallocz(s->fifo_size * sizeof(s->event_fifo[0]));
+ s->event_fifo = g_malloc0(s->fifo_size * sizeof(s->event_fifo[0]));
qemu_add_mouse_event_handler(syborg_pointer_event, s, s->absolute,
"Syborg Pointer");
diff --git a/hw/syborg_serial.c b/hw/syborg_serial.c
index 2ef71758b..4d0ec04e3 100644
--- a/hw/syborg_serial.c
+++ b/hw/syborg_serial.c
@@ -311,7 +311,7 @@ static int syborg_serial_init(SysBusDevice *dev)
fprintf(stderr, "syborg_serial: fifo too small\n");
s->fifo_size = 16;
}
- s->read_fifo = qemu_mallocz(s->fifo_size * sizeof(s->read_fifo[0]));
+ s->read_fifo = g_malloc0(s->fifo_size * sizeof(s->read_fifo[0]));
return 0;
}
diff --git a/hw/sysbus.c b/hw/sysbus.c
index ea442acb5..f8f174665 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -158,8 +158,8 @@ void sysbus_register_dev(const char *name, size_t size, sysbus_initfn init)
{
SysBusDeviceInfo *info;
- info = qemu_mallocz(sizeof(*info));
- info->qdev.name = qemu_strdup(name);
+ info = g_malloc0(sizeof(*info));
+ info->qdev.name = g_strdup(name);
info->qdev.size = size;
info->init = init;
sysbus_register_withprop(info);
diff --git a/hw/tc58128.c b/hw/tc58128.c
index 61b99dd4d..ee3ecad51 100644
--- a/hw/tc58128.c
+++ b/hw/tc58128.c
@@ -30,7 +30,7 @@ static void init_dev(tc58128_dev * dev, const char *filename)
int ret, blocks;
dev->state = WAIT;
- dev->flash_contents = qemu_mallocz(FLASH_SIZE);
+ dev->flash_contents = g_malloc0(FLASH_SIZE);
memset(dev->flash_contents, 0xff, FLASH_SIZE);
if (!dev->flash_contents) {
fprintf(stderr, "could not alloc memory for flash\n");
diff --git a/hw/tc6393xb.c b/hw/tc6393xb.c
index a1c48bf1d..c28005a86 100644
--- a/hw/tc6393xb.c
+++ b/hw/tc6393xb.c
@@ -579,7 +579,7 @@ TC6393xbState *tc6393xb_init(uint32_t base, qemu_irq irq)
tc6393xb_writel,
};
- s = (TC6393xbState *) qemu_mallocz(sizeof(TC6393xbState));
+ s = (TC6393xbState *) g_malloc0(sizeof(TC6393xbState));
s->irq = irq;
s->gpio_in = qemu_allocate_irqs(tc6393xb_gpio_set, s, TC6393XB_GPIOS);
diff --git a/hw/tsc2005.c b/hw/tsc2005.c
index c95dcf06a..9a500ebb3 100644
--- a/hw/tsc2005.c
+++ b/hw/tsc2005.c
@@ -524,7 +524,7 @@ void *tsc2005_init(qemu_irq pintdav)
TSC2005State *s;
s = (TSC2005State *)
- qemu_mallocz(sizeof(TSC2005State));
+ g_malloc0(sizeof(TSC2005State));
s->x = 400;
s->y = 240;
s->pressure = 0;
diff --git a/hw/tsc210x.c b/hw/tsc210x.c
index 96446dd46..3c448a6f0 100644
--- a/hw/tsc210x.c
+++ b/hw/tsc210x.c
@@ -1105,7 +1105,7 @@ uWireSlave *tsc2102_init(qemu_irq pint)
TSC210xState *s;
s = (TSC210xState *)
- qemu_mallocz(sizeof(TSC210xState));
+ g_malloc0(sizeof(TSC210xState));
memset(s, 0, sizeof(TSC210xState));
s->x = 160;
s->y = 160;
@@ -1154,7 +1154,7 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav)
TSC210xState *s;
s = (TSC210xState *)
- qemu_mallocz(sizeof(TSC210xState));
+ g_malloc0(sizeof(TSC210xState));
memset(s, 0, sizeof(TSC210xState));
s->x = 400;
s->y = 240;
diff --git a/hw/tusb6010.c b/hw/tusb6010.c
index ccd01ad44..d7ae527a5 100644
--- a/hw/tusb6010.c
+++ b/hw/tusb6010.c
@@ -729,7 +729,7 @@ static void tusb_musb_core_intr(void *opaque, int source, int level)
TUSBState *tusb6010_init(qemu_irq intr)
{
- TUSBState *s = qemu_mallocz(sizeof(*s));
+ TUSBState *s = g_malloc0(sizeof(*s));
s->test_reset = TUSB_PROD_TEST_RESET_VAL;
s->host_mode = 0;
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index f1dd55ecc..c0bbc7c6b 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -342,7 +342,7 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
static char *usb_get_dev_path(DeviceState *qdev)
{
USBDevice *dev = DO_UPCAST(USBDevice, qdev, qdev);
- return qemu_strdup(dev->port->path);
+ return g_strdup(dev->port->path);
}
static char *usb_get_fw_dev_path(DeviceState *qdev)
@@ -353,7 +353,7 @@ static char *usb_get_fw_dev_path(DeviceState *qdev)
long nr;
fw_len = 32 + strlen(dev->port->path) * 6;
- fw_path = qemu_malloc(fw_len);
+ fw_path = g_malloc(fw_len);
in = dev->port->path;
while (fw_len - pos > 0) {
nr = strtol(in, &in, 10);
diff --git a/hw/usb-desc.c b/hw/usb-desc.c
index bc6858f62..ae2d384bb 100644
--- a/hw/usb-desc.c
+++ b/hw/usb-desc.c
@@ -283,12 +283,12 @@ void usb_desc_set_string(USBDevice *dev, uint8_t index, const char *str)
}
}
if (s == NULL) {
- s = qemu_mallocz(sizeof(*s));
+ s = g_malloc0(sizeof(*s));
s->index = index;
QLIST_INSERT_HEAD(&dev->strings, s, next);
}
- qemu_free(s->str);
- s->str = qemu_strdup(str);
+ g_free(s->str);
+ s->str = g_strdup(str);
}
const char *usb_desc_get_string(USBDevice *dev, uint8_t index)
diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index c9d0a692e..47a7fb9de 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -652,7 +652,7 @@ static EHCIQueue *ehci_alloc_queue(EHCIState *ehci, int async)
{
EHCIQueue *q;
- q = qemu_mallocz(sizeof(*q));
+ q = g_malloc0(sizeof(*q));
q->ehci = ehci;
q->async_schedule = async;
QTAILQ_INSERT_HEAD(&ehci->queues, q, next);
@@ -667,7 +667,7 @@ static void ehci_free_queue(EHCIQueue *q)
usb_cancel_packet(&q->packet);
}
QTAILQ_REMOVE(&q->ehci->queues, q, next);
- qemu_free(q);
+ g_free(q);
}
static EHCIQueue *ehci_find_queue_by_qh(EHCIState *ehci, uint32_t addr)
diff --git a/hw/usb-musb.c b/hw/usb-musb.c
index d3ccde919..799fa6e18 100644
--- a/hw/usb-musb.c
+++ b/hw/usb-musb.c
@@ -342,7 +342,7 @@ struct MUSBState {
struct MUSBState *musb_init(qemu_irq *irqs)
{
- MUSBState *s = qemu_mallocz(sizeof(*s));
+ MUSBState *s = g_malloc0(sizeof(*s));
int i;
s->irqs = irqs;
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 0cb47d63b..a8b7c8dd7 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -844,7 +844,7 @@ static int rndis_get_response(USBNetState *s, uint8_t *buf)
QTAILQ_REMOVE(&s->rndis_resp, r, entries);
ret = r->length;
memcpy(buf, r->buf, r->length);
- qemu_free(r);
+ g_free(r);
return ret;
}
@@ -852,7 +852,7 @@ static int rndis_get_response(USBNetState *s, uint8_t *buf)
static void *rndis_queue_response(USBNetState *s, unsigned int length)
{
struct rndis_response *r =
- qemu_mallocz(sizeof(struct rndis_response) + length);
+ g_malloc0(sizeof(struct rndis_response) + length);
QTAILQ_INSERT_TAIL(&s->rndis_resp, r, entries);
r->length = length;
@@ -866,7 +866,7 @@ static void rndis_clear_responsequeue(USBNetState *s)
while ((r = s->rndis_resp.tqh_first)) {
QTAILQ_REMOVE(&s->rndis_resp, r, entries);
- qemu_free(r);
+ g_free(r);
}
}
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 16088d7dc..6ca7ca81e 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -168,7 +168,7 @@ typedef struct UHCI_QH {
static UHCIAsync *uhci_async_alloc(UHCIState *s)
{
- UHCIAsync *async = qemu_malloc(sizeof(UHCIAsync));
+ UHCIAsync *async = g_malloc(sizeof(UHCIAsync));
memset(&async->packet, 0, sizeof(async->packet));
async->uhci = s;
@@ -187,7 +187,7 @@ static void uhci_async_free(UHCIState *s, UHCIAsync *async)
{
usb_packet_cleanup(&async->packet);
qemu_sglist_destroy(&async->sgl);
- qemu_free(async);
+ g_free(async);
}
static void uhci_async_link(UHCIState *s, UHCIAsync *async)
diff --git a/hw/vga-isa-mm.c b/hw/vga-isa-mm.c
index 96e6e7dd2..b93497803 100644
--- a/hw/vga-isa-mm.c
+++ b/hw/vga-isa-mm.c
@@ -102,11 +102,11 @@ static void vga_mm_init(ISAVGAMMState *s, target_phys_addr_t vram_base,
MemoryRegion *s_ioport_ctrl, *vga_io_memory;
s->it_shift = it_shift;
- s_ioport_ctrl = qemu_malloc(sizeof(*s_ioport_ctrl));
+ s_ioport_ctrl = g_malloc(sizeof(*s_ioport_ctrl));
memory_region_init_io(s_ioport_ctrl, &vga_mm_ctrl_ops, s,
"vga-mm-ctrl", 0x100000);
- vga_io_memory = qemu_malloc(sizeof(*vga_io_memory));
+ vga_io_memory = g_malloc(sizeof(*vga_io_memory));
/* XXX: endianness? */
memory_region_init_io(vga_io_memory, &vga_mem_ops, &s->vga,
"vga-mem", 0x20000);
@@ -125,7 +125,7 @@ int isa_vga_mm_init(target_phys_addr_t vram_base,
{
ISAVGAMMState *s;
- s = qemu_mallocz(sizeof(*s));
+ s = g_malloc0(sizeof(*s));
vga_common_init(&s->vga, VGA_RAM_SIZE);
vga_mm_init(s, vram_base, ctrl_base, it_shift);
diff --git a/hw/vga.c b/hw/vga.c
index 33dc478a7..a190105b1 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2234,7 +2234,7 @@ MemoryRegion *vga_init_io(VGACommonState *s)
#endif
#endif /* CONFIG_BOCHS_VBE */
- vga_mem = qemu_malloc(sizeof(*vga_mem));
+ vga_mem = g_malloc(sizeof(*vga_mem));
memory_region_init_io(vga_mem, &vga_mem_ops, s,
"vga-lowmem", 0x20000);
@@ -2302,7 +2302,7 @@ int ppm_save(const char *filename, struct DisplaySurface *ds)
return -1;
fprintf(f, "P6\n%d %d\n%d\n",
ds->width, ds->height, 255);
- linebuf = qemu_malloc(ds->width * 3);
+ linebuf = g_malloc(ds->width * 3);
d1 = ds->data;
for(y = 0; y < ds->height; y++) {
d = d1;
@@ -2327,7 +2327,7 @@ int ppm_save(const char *filename, struct DisplaySurface *ds)
ret = fwrite(linebuf, 1, pbuf - linebuf, f);
(void)ret;
}
- qemu_free(linebuf);
+ g_free(linebuf);
fclose(f);
return 0;
}
@@ -2336,7 +2336,7 @@ static DisplayChangeListener* vga_screen_dump_init(DisplayState *ds)
{
DisplayChangeListener *dcl;
- dcl = qemu_mallocz(sizeof(DisplayChangeListener));
+ dcl = g_malloc0(sizeof(DisplayChangeListener));
dcl->dpy_update = vga_save_dpy_update;
dcl->dpy_resize = vga_save_dpy_resize;
dcl->dpy_refresh = vga_save_dpy_refresh;
diff --git a/hw/vhost.c b/hw/vhost.c
index 19e72555c..18860678b 100644
--- a/hw/vhost.c
+++ b/hw/vhost.c
@@ -252,7 +252,7 @@ static inline void vhost_dev_log_resize(struct vhost_dev* dev, uint64_t size)
uint64_t log_base;
int r;
if (size) {
- log = qemu_mallocz(size * sizeof *log);
+ log = g_malloc0(size * sizeof *log);
} else {
log = NULL;
}
@@ -262,7 +262,7 @@ static inline void vhost_dev_log_resize(struct vhost_dev* dev, uint64_t size)
vhost_client_sync_dirty_bitmap(&dev->client, 0,
(target_phys_addr_t)~0x0ull);
if (dev->log) {
- qemu_free(dev->log);
+ g_free(dev->log);
}
dev->log = log;
dev->log_size = size;
@@ -348,7 +348,7 @@ static void vhost_client_set_memory(CPUPhysMemoryClient *client,
uint64_t log_size;
int r;
- dev->mem = qemu_realloc(dev->mem, s);
+ dev->mem = g_realloc(dev->mem, s);
if (log_dirty) {
flags = IO_MEM_UNASSIGNED;
@@ -485,7 +485,7 @@ static int vhost_client_migration_log(CPUPhysMemoryClient *client,
return r;
}
if (dev->log) {
- qemu_free(dev->log);
+ g_free(dev->log);
}
dev->log = NULL;
dev->log_size = 0;
@@ -669,7 +669,7 @@ int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force)
hdev->client.migration_log = vhost_client_migration_log;
hdev->client.log_start = NULL;
hdev->client.log_stop = NULL;
- hdev->mem = qemu_mallocz(offsetof(struct vhost_memory, regions));
+ hdev->mem = g_malloc0(offsetof(struct vhost_memory, regions));
hdev->log = NULL;
hdev->log_size = 0;
hdev->log_enabled = false;
@@ -686,7 +686,7 @@ fail:
void vhost_dev_cleanup(struct vhost_dev *hdev)
{
cpu_unregister_phys_memory_client(&hdev->client);
- qemu_free(hdev->mem);
+ g_free(hdev->mem);
close(hdev->control);
}
@@ -734,7 +734,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
if (hdev->log_enabled) {
hdev->log_size = vhost_get_log_size(hdev);
hdev->log = hdev->log_size ?
- qemu_mallocz(hdev->log_size * sizeof *hdev->log) : NULL;
+ g_malloc0(hdev->log_size * sizeof *hdev->log) : NULL;
r = ioctl(hdev->control, VHOST_SET_LOG_BASE,
(uint64_t)(unsigned long)hdev->log);
if (r < 0) {
@@ -782,7 +782,7 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev)
assert (r >= 0);
hdev->started = false;
- qemu_free(hdev->log);
+ g_free(hdev->log);
hdev->log = NULL;
hdev->log_size = 0;
}
diff --git a/hw/vhost_net.c b/hw/vhost_net.c
index b6dc592db..a55981200 100644
--- a/hw/vhost_net.c
+++ b/hw/vhost_net.c
@@ -92,7 +92,7 @@ struct vhost_net *vhost_net_init(VLANClientState *backend, int devfd,
bool force)
{
int r;
- struct vhost_net *net = qemu_malloc(sizeof *net);
+ struct vhost_net *net = g_malloc(sizeof *net);
if (!backend) {
fprintf(stderr, "vhost-net requires backend to be setup\n");
goto fail;
@@ -125,7 +125,7 @@ struct vhost_net *vhost_net_init(VLANClientState *backend, int devfd,
vhost_net_ack_features(net, 0);
return net;
fail:
- qemu_free(net);
+ g_free(net);
return NULL;
}
@@ -198,7 +198,7 @@ void vhost_net_cleanup(struct vhost_net *net)
if (net->dev.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {
tap_set_vnet_hdr_len(net->vc, sizeof(struct virtio_net_hdr));
}
- qemu_free(net);
+ g_free(net);
}
#else
struct vhost_net *vhost_net_init(VLANClientState *backend, int devfd,
diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c
index 7bde8c79d..333050cda 100644
--- a/hw/virtex_ml507.c
+++ b/hw/virtex_ml507.c
@@ -102,7 +102,7 @@ static CPUState *ppc440_init_xilinx(ram_addr_t *ram_size,
ppc_dcr_init(env, NULL, NULL);
/* interrupt controller */
- irqs = qemu_mallocz(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
+ irqs = g_malloc0(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
irqs[PPCUIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
irqs[PPCUIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];
ppcuic_init(env, irqs, 0x0C0, 0, 1);
@@ -154,7 +154,7 @@ static int xilinx_load_device_tree(target_phys_addr_t addr,
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (path) {
fdt = load_device_tree(path, &fdt_size);
- qemu_free(path);
+ g_free(path);
}
if (!fdt) {
return 0;
@@ -173,7 +173,7 @@ static int xilinx_load_device_tree(target_phys_addr_t addr,
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (path) {
fdt_size = load_image_targphys(path, addr, 0x10000);
- qemu_free(path);
+ g_free(path);
}
}
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 836dbc3c1..dad8c0a6a 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -59,7 +59,7 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, int status)
virtqueue_push(s->vq, &req->elem, req->qiov.size + sizeof(*req->in));
virtio_notify(&s->vdev, s->vq);
- qemu_free(req);
+ g_free(req);
}
static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
@@ -117,7 +117,7 @@ static void virtio_blk_flush_complete(void *opaque, int ret)
static VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s)
{
- VirtIOBlockReq *req = qemu_malloc(sizeof(*req));
+ VirtIOBlockReq *req = g_malloc(sizeof(*req));
req->dev = s;
req->qiov.size = 0;
req->next = NULL;
@@ -130,7 +130,7 @@ static VirtIOBlockReq *virtio_blk_get_request(VirtIOBlock *s)
if (req != NULL) {
if (!virtqueue_pop(s->vq, &req->elem)) {
- qemu_free(req);
+ g_free(req);
return NULL;
}
}
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 3f10391f3..8c2f46014 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -1039,9 +1039,9 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
n->mergeable_rx_bufs = 0;
n->promisc = 1; /* for compatibility */
- n->mac_table.macs = qemu_mallocz(MAC_TABLE_ENTRIES * ETH_ALEN);
+ n->mac_table.macs = g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN);
- n->vlans = qemu_mallocz(MAX_VLAN >> 3);
+ n->vlans = g_malloc0(MAX_VLAN >> 3);
n->qdev = dev;
register_savevm(dev, "virtio-net", -1, VIRTIO_NET_VM_VERSION,
@@ -1063,8 +1063,8 @@ void virtio_net_exit(VirtIODevice *vdev)
unregister_savevm(n->qdev, "virtio-net", n);
- qemu_free(n->mac_table.macs);
- qemu_free(n->vlans);
+ g_free(n->mac_table.macs);
+ g_free(n->vlans);
if (n->tx_timer) {
qemu_del_timer(n->tx_timer);
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index c5eb93109..a4825b9ee 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -383,14 +383,14 @@ static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len)
stw_p(&cpkt.value, 1);
buffer_len = sizeof(cpkt) + strlen(port->name) + 1;
- buffer = qemu_malloc(buffer_len);
+ buffer = g_malloc(buffer_len);
memcpy(buffer, &cpkt, sizeof(cpkt));
memcpy(buffer + sizeof(cpkt), port->name, strlen(port->name));
buffer[buffer_len - 1] = 0;
send_control_msg(port, buffer, buffer_len);
- qemu_free(buffer);
+ g_free(buffer);
}
if (port->host_connected) {
@@ -447,9 +447,9 @@ static void control_out(VirtIODevice *vdev, VirtQueue *vq)
* if the size of the buf differs
*/
if (cur_len > len) {
- qemu_free(buf);
+ g_free(buf);
- buf = qemu_malloc(cur_len);
+ buf = g_malloc(cur_len);
len = cur_len;
}
copied = iov_to_buf(elem.out_sg, elem.out_num, buf, 0, len);
@@ -457,7 +457,7 @@ static void control_out(VirtIODevice *vdev, VirtQueue *vq)
handle_control_message(vser, buf, copied);
virtqueue_push(vq, &elem, 0);
}
- qemu_free(buf);
+ g_free(buf);
virtio_notify(vdev, vq);
}
@@ -862,8 +862,8 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
QTAILQ_INIT(&vser->ports);
vser->bus.max_nr_ports = conf->max_virtserial_ports;
- vser->ivqs = qemu_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
- vser->ovqs = qemu_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
+ vser->ivqs = g_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
+ vser->ovqs = g_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
/* Add a queue for host to guest transfers for port 0 (backward compat) */
vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);
@@ -889,7 +889,7 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
}
vser->config.max_nr_ports = tswap32(conf->max_virtserial_ports);
- vser->ports_map = qemu_mallocz(((conf->max_virtserial_ports + 31) / 32)
+ vser->ports_map = g_malloc0(((conf->max_virtserial_ports + 31) / 32)
* sizeof(vser->ports_map[0]));
/*
* Reserve location 0 for a console port for backward compat
@@ -919,9 +919,9 @@ void virtio_serial_exit(VirtIODevice *vdev)
unregister_savevm(vser->qdev, "virtio-console", vser);
- qemu_free(vser->ivqs);
- qemu_free(vser->ovqs);
- qemu_free(vser->ports_map);
+ g_free(vser->ivqs);
+ g_free(vser->ovqs);
+ g_free(vser->ports_map);
virtio_cleanup(vdev);
}
diff --git a/hw/virtio.c b/hw/virtio.c
index 93dfb1e35..13aa0faf2 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -832,9 +832,9 @@ void virtio_cleanup(VirtIODevice *vdev)
{
qemu_del_vm_change_state_handler(vdev->vmstate);
if (vdev->config)
- qemu_free(vdev->config);
- qemu_free(vdev->vq);
- qemu_free(vdev);
+ g_free(vdev->config);
+ g_free(vdev->vq);
+ g_free(vdev);
}
static void virtio_vmstate_change(void *opaque, int running, int reason)
@@ -862,14 +862,14 @@ VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
VirtIODevice *vdev;
int i;
- vdev = qemu_mallocz(struct_size);
+ vdev = g_malloc0(struct_size);
vdev->device_id = device_id;
vdev->status = 0;
vdev->isr = 0;
vdev->queue_sel = 0;
vdev->config_vector = VIRTIO_NO_VECTOR;
- vdev->vq = qemu_mallocz(sizeof(VirtQueue) * VIRTIO_PCI_QUEUE_MAX);
+ vdev->vq = g_malloc0(sizeof(VirtQueue) * VIRTIO_PCI_QUEUE_MAX);
vdev->vm_running = vm_running;
for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
vdev->vq[i].vector = VIRTIO_NO_VECTOR;
@@ -879,7 +879,7 @@ VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
vdev->name = name;
vdev->config_len = config_size;
if (vdev->config_len)
- vdev->config = qemu_mallocz(config_size);
+ vdev->config = g_malloc0(config_size);
else
vdev->config = NULL;
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index d5cfa70cb..a840cbd4b 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1068,7 +1068,7 @@ static void vmsvga_screen_dump(void *opaque, const char *filename)
DisplaySurface *ds = qemu_create_displaysurface_from(s->width,
s->height, 32, ds_get_linesize(s->vga.ds), s->vga.vram_ptr);
ppm_save(filename, ds);
- qemu_free(ds);
+ g_free(ds);
}
}
@@ -1210,7 +1210,7 @@ static const VMStateDescription vmstate_vmware_vga = {
static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
{
s->scratch_size = SVGA_SCRATCH_SIZE;
- s->scratch = qemu_malloc(s->scratch_size * 4);
+ s->scratch = g_malloc(s->scratch_size * 4);
s->vga.ds = graphic_console_init(vmsvga_update_display,
vmsvga_invalidate_display,
@@ -1274,7 +1274,7 @@ static int pci_vmsvga_initfn(PCIDevice *dev)
MemoryRegion *iomem;
#ifdef DIRECT_VRAM
- DirectMem *directmem = qemu_malloc(sizeof(*directmem));
+ DirectMem *directmem = g_malloc(sizeof(*directmem));
iomem = &directmem->mr;
memory_region_init_io(iomem, &vmsvga_vram_io_ops, &s->chip, "vmsvga",
diff --git a/hw/wm8750.c b/hw/wm8750.c
index c9c674451..39383f43e 100644
--- a/hw/wm8750.c
+++ b/hw/wm8750.c
@@ -625,7 +625,7 @@ static void wm8750_fini(i2c_slave *i2c)
WM8750State *s = (WM8750State *) i2c;
wm8750_reset(&s->i2c);
AUD_remove_card(&s->card);
- qemu_free(s);
+ g_free(s);
}
#endif
diff --git a/hw/xen_backend.c b/hw/xen_backend.c
index d881fa2f7..aa642675f 100644
--- a/hw/xen_backend.c
+++ b/hw/xen_backend.c
@@ -75,8 +75,8 @@ char *xenstore_read_str(const char *base, const char *node)
str = xs_read(xenstore, 0, abspath, &len);
if (str != NULL) {
/* move to qemu-allocated memory to make sure
- * callers can savely qemu_free() stuff. */
- ret = qemu_strdup(str);
+ * callers can savely g_free() stuff. */
+ ret = g_strdup(str);
free(str);
}
return ret;
@@ -99,7 +99,7 @@ int xenstore_read_int(const char *base, const char *node, int *ival)
if (val && 1 == sscanf(val, "%d", ival)) {
rc = 0;
}
- qemu_free(val);
+ g_free(val);
return rc;
}
@@ -199,7 +199,7 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
}
/* init new xendev */
- xendev = qemu_mallocz(ops->size);
+ xendev = g_malloc0(ops->size);
xendev->type = type;
xendev->dom = dom;
xendev->dev = dev;
@@ -218,7 +218,7 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
xendev->evtchndev = xen_xc_evtchn_open(NULL, 0);
if (xendev->evtchndev == XC_HANDLER_INITIAL_VALUE) {
xen_be_printf(NULL, 0, "can't open evtchn device\n");
- qemu_free(xendev);
+ g_free(xendev);
return NULL;
}
fcntl(xc_evtchn_fd(xendev->evtchndev), F_SETFD, FD_CLOEXEC);
@@ -228,7 +228,7 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
if (xendev->gnttabdev == XC_HANDLER_INITIAL_VALUE) {
xen_be_printf(NULL, 0, "can't open gnttab device\n");
xc_evtchn_close(xendev->evtchndev);
- qemu_free(xendev);
+ g_free(xendev);
return NULL;
}
} else {
@@ -275,7 +275,7 @@ static struct XenDevice *xen_be_del_xendev(int dom, int dev)
char token[XEN_BUFSIZE];
snprintf(token, sizeof(token), "fe:%p", xendev);
xs_unwatch(xenstore, xendev->fe, token);
- qemu_free(xendev->fe);
+ g_free(xendev->fe);
}
if (xendev->evtchndev != XC_HANDLER_INITIAL_VALUE) {
@@ -286,7 +286,7 @@ static struct XenDevice *xen_be_del_xendev(int dom, int dev)
}
QTAILQ_REMOVE(&xendevs, xendev, next);
- qemu_free(xendev);
+ g_free(xendev);
}
return NULL;
}
@@ -328,7 +328,7 @@ static void xen_be_frontend_changed(struct XenDevice *xendev, const char *node)
xendev->fe_state = fe_state;
}
if (node == NULL || strcmp(node, "protocol") == 0) {
- qemu_free(xendev->protocol);
+ g_free(xendev->protocol);
xendev->protocol = xenstore_read_fe_str(xendev, "protocol");
if (xendev->protocol) {
xen_be_printf(xendev, 1, "frontend protocol: %s\n", xendev->protocol);
diff --git a/hw/xen_console.c b/hw/xen_console.c
index 8ef104c9a..99ff442f8 100644
--- a/hw/xen_console.c
+++ b/hw/xen_console.c
@@ -70,7 +70,7 @@ static void buffer_append(struct XenConsole *con)
if ((buffer->capacity - buffer->size) < size) {
buffer->capacity += (size + 1024);
- buffer->data = qemu_realloc(buffer->data, buffer->capacity);
+ buffer->data = g_realloc(buffer->data, buffer->capacity);
}
while (cons != prod)
@@ -89,7 +89,7 @@ static void buffer_append(struct XenConsole *con)
uint8_t *maxpos = buffer->data + buffer->max_capacity;
memmove(maxpos - over, maxpos, over);
- buffer->data = qemu_realloc(buffer->data, buffer->max_capacity);
+ buffer->data = g_realloc(buffer->data, buffer->max_capacity);
buffer->size = buffer->capacity = buffer->max_capacity;
if (buffer->consumed > buffer->max_capacity - over)
@@ -208,7 +208,7 @@ static int con_init(struct XenDevice *xendev)
xenstore_store_pv_console_info(con->xendev.dev, con->chr);
out:
- qemu_free(type);
+ g_free(type);
return ret;
}
diff --git a/hw/xen_devconfig.c b/hw/xen_devconfig.c
index 6926c54f4..41accbbfa 100644
--- a/hw/xen_devconfig.c
+++ b/hw/xen_devconfig.c
@@ -14,7 +14,7 @@ static void xen_config_cleanup_dir(char *dir)
{
struct xs_dirs *d;
- d = qemu_malloc(sizeof(*d));
+ d = g_malloc(sizeof(*d));
d->xs_dir = dir;
QTAILQ_INSERT_TAIL(&xs_cleanup, d, list);
}
@@ -43,7 +43,7 @@ static int xen_config_dev_mkdir(char *dev, int p)
xen_be_printf(NULL, 0, "xs_mkdir %s: failed\n", dev);
return -1;
}
- xen_config_cleanup_dir(qemu_strdup(dev));
+ xen_config_cleanup_dir(g_strdup(dev));
if (!xs_set_permissions(xenstore, 0, dev, perms, 2)) {
xen_be_printf(NULL, 0, "xs_set_permissions %s: failed\n", dev);
diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index add815f27..31f91514f 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -124,7 +124,7 @@ static struct ioreq *ioreq_start(struct XenBlkDev *blkdev)
goto out;
}
/* allocate new struct */
- ioreq = qemu_mallocz(sizeof(*ioreq));
+ ioreq = g_malloc0(sizeof(*ioreq));
ioreq->blkdev = blkdev;
blkdev->requests_total++;
qemu_iovec_init(&ioreq->v, BLKIF_MAX_SEGMENTS_PER_REQUEST);
@@ -716,15 +716,15 @@ static int blk_init(struct XenDevice *xendev)
return 0;
out_error:
- qemu_free(blkdev->params);
+ g_free(blkdev->params);
blkdev->params = NULL;
- qemu_free(blkdev->mode);
+ g_free(blkdev->mode);
blkdev->mode = NULL;
- qemu_free(blkdev->type);
+ g_free(blkdev->type);
blkdev->type = NULL;
- qemu_free(blkdev->dev);
+ g_free(blkdev->dev);
blkdev->dev = NULL;
- qemu_free(blkdev->devtype);
+ g_free(blkdev->devtype);
blkdev->devtype = NULL;
return -1;
}
@@ -822,14 +822,14 @@ static int blk_free(struct XenDevice *xendev)
ioreq = QLIST_FIRST(&blkdev->freelist);
QLIST_REMOVE(ioreq, list);
qemu_iovec_destroy(&ioreq->v);
- qemu_free(ioreq);
+ g_free(ioreq);
}
- qemu_free(blkdev->params);
- qemu_free(blkdev->mode);
- qemu_free(blkdev->type);
- qemu_free(blkdev->dev);
- qemu_free(blkdev->devtype);
+ g_free(blkdev->params);
+ g_free(blkdev->mode);
+ g_free(blkdev->type);
+ g_free(blkdev->dev);
+ g_free(blkdev->devtype);
qemu_bh_delete(blkdev->bh);
return 0;
}
diff --git a/hw/xen_nic.c b/hw/xen_nic.c
index ff86491cf..b28b15670 100644
--- a/hw/xen_nic.c
+++ b/hw/xen_nic.c
@@ -183,7 +183,7 @@ static void net_tx_packets(struct XenNetDev *netdev)
if (txreq.flags & NETTXF_csum_blank) {
/* have read-only mapping -> can't fill checksum in-place */
if (!tmpbuf) {
- tmpbuf = qemu_malloc(XC_PAGE_SIZE);
+ tmpbuf = g_malloc(XC_PAGE_SIZE);
}
memcpy(tmpbuf, page + txreq.offset, txreq.size);
net_checksum_calculate(tmpbuf, txreq.size);
@@ -199,7 +199,7 @@ static void net_tx_packets(struct XenNetDev *netdev)
}
netdev->tx_work = 0;
}
- qemu_free(tmpbuf);
+ g_free(tmpbuf);
}
/* ------------------------------------------------------------- */
@@ -423,7 +423,7 @@ static int net_free(struct XenDevice *xendev)
{
struct XenNetDev *netdev = container_of(xendev, struct XenNetDev, xendev);
- qemu_free(netdev->mac);
+ g_free(netdev->mac);
return 0;
}
diff --git a/hw/xenfb.c b/hw/xenfb.c
index 0a01ae30c..d532d3e89 100644
--- a/hw/xenfb.c
+++ b/hw/xenfb.c
@@ -366,7 +366,7 @@ static int input_connect(struct XenDevice *xendev)
/* there is no vfb, run vkbd on its own */
in->c.ds = get_displaystate();
} else {
- qemu_free(vfb);
+ g_free(vfb);
xen_be_printf(xendev, 1, "ds not set (yet)\n");
return -1;
}
@@ -483,8 +483,8 @@ static int xenfb_map_fb(struct XenFB *xenfb)
n_fbdirs = xenfb->fbpages * mode / 8;
n_fbdirs = (n_fbdirs + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;
- pgmfns = qemu_mallocz(sizeof(unsigned long) * n_fbdirs);
- fbmfns = qemu_mallocz(sizeof(unsigned long) * xenfb->fbpages);
+ pgmfns = g_malloc0(sizeof(unsigned long) * n_fbdirs);
+ fbmfns = g_malloc0(sizeof(unsigned long) * xenfb->fbpages);
xenfb_copy_mfns(mode, n_fbdirs, pgmfns, pd);
map = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom,
@@ -502,8 +502,8 @@ static int xenfb_map_fb(struct XenFB *xenfb)
ret = 0; /* all is fine */
out:
- qemu_free(pgmfns);
- qemu_free(fbmfns);
+ g_free(pgmfns);
+ g_free(fbmfns);
return ret;
}
diff --git a/hw/xics.c b/hw/xics.c
index 13a1d2594..9bf82aaf2 100644
--- a/hw/xics.c
+++ b/hw/xics.c
@@ -440,9 +440,9 @@ struct icp_state *xics_system_init(int nr_irqs)
}
}
- icp = qemu_mallocz(sizeof(*icp));
+ icp = g_malloc0(sizeof(*icp));
icp->nr_servers = max_server_num + 1;
- icp->ss = qemu_mallocz(icp->nr_servers*sizeof(struct icp_server_state));
+ icp->ss = g_malloc0(icp->nr_servers*sizeof(struct icp_server_state));
for (i = 0; i < icp->nr_servers; i++) {
icp->ss[i].mfrr = 0xff;
@@ -467,10 +467,10 @@ struct icp_state *xics_system_init(int nr_irqs)
}
}
- ics = qemu_mallocz(sizeof(*ics));
+ ics = g_malloc0(sizeof(*ics));
ics->nr_irqs = nr_irqs;
ics->offset = 16;
- ics->irqs = qemu_mallocz(nr_irqs * sizeof(struct ics_irq_state));
+ ics->irqs = g_malloc0(nr_irqs * sizeof(struct ics_irq_state));
icp->ics = ics;
ics->icp = icp;
diff --git a/hw/xilinx_axienet.c b/hw/xilinx_axienet.c
index 464d275ad..b875aad01 100644
--- a/hw/xilinx_axienet.c
+++ b/hw/xilinx_axienet.c
@@ -789,8 +789,8 @@ static void eth_cleanup(VLANClientState *nc)
{
/* FIXME. */
struct XilinxAXIEnet *s = DO_UPCAST(NICState, nc, nc)->opaque;
- qemu_free(s->rxmem);
- qemu_free(s);
+ g_free(s->rxmem);
+ g_free(s);
}
static void
@@ -871,7 +871,7 @@ static int xilinx_enet_init(SysBusDevice *dev)
s->TEMAC.parent = s;
- s->rxmem = qemu_malloc(s->c_rxmem);
+ s->rxmem = g_malloc(s->c_rxmem);
axienet_reset(s);
return 0;
diff --git a/hw/xilinx_timer.c b/hw/xilinx_timer.c
index d398c18e9..f1c7abc99 100644
--- a/hw/xilinx_timer.c
+++ b/hw/xilinx_timer.c
@@ -198,7 +198,7 @@ static int xilinx_timer_init(SysBusDevice *dev)
sysbus_init_irq(dev, &t->irq);
/* Init all the ptimers. */
- t->timers = qemu_mallocz(sizeof t->timers[0] * t->nr_timers);
+ t->timers = g_malloc0(sizeof t->timers[0] * t->nr_timers);
for (i = 0; i < t->nr_timers; i++) {
struct xlx_timer *xt = &t->timers[i];
diff --git a/input.c b/input.c
index 310bad58f..e2f7c92a7 100644
--- a/input.c
+++ b/input.c
@@ -73,12 +73,12 @@ QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
QEMUPutMouseEntry *s;
static int mouse_index = 0;
- s = qemu_mallocz(sizeof(QEMUPutMouseEntry));
+ s = g_malloc0(sizeof(QEMUPutMouseEntry));
s->qemu_put_mouse_event = func;
s->qemu_put_mouse_event_opaque = opaque;
s->qemu_put_mouse_event_absolute = absolute;
- s->qemu_put_mouse_event_name = qemu_strdup(name);
+ s->qemu_put_mouse_event_name = g_strdup(name);
s->index = mouse_index++;
QTAILQ_INSERT_TAIL(&mouse_handlers, s, node);
@@ -100,8 +100,8 @@ void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry)
{
QTAILQ_REMOVE(&mouse_handlers, entry, node);
- qemu_free(entry->qemu_put_mouse_event_name);
- qemu_free(entry);
+ g_free(entry->qemu_put_mouse_event_name);
+ g_free(entry);
check_mode_change();
}
@@ -111,7 +111,7 @@ QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func,
{
QEMUPutLEDEntry *s;
- s = qemu_mallocz(sizeof(QEMUPutLEDEntry));
+ s = g_malloc0(sizeof(QEMUPutLEDEntry));
s->put_led = func;
s->opaque = opaque;
@@ -124,7 +124,7 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry)
if (entry == NULL)
return;
QTAILQ_REMOVE(&led_handlers, entry, next);
- qemu_free(entry);
+ g_free(entry);
}
void kbd_put_keycode(int keycode)
diff --git a/iohandler.c b/iohandler.c
index 2b824218e..4deae1e6a 100644
--- a/iohandler.c
+++ b/iohandler.c
@@ -67,7 +67,7 @@ int qemu_set_fd_handler2(int fd,
if (ioh->fd == fd)
goto found;
}
- ioh = qemu_mallocz(sizeof(IOHandlerRecord));
+ ioh = g_malloc0(sizeof(IOHandlerRecord));
QLIST_INSERT_HEAD(&io_handlers, ioh, next);
found:
ioh->fd = fd;
@@ -126,7 +126,7 @@ void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int re
/* Do this last in case read/write handlers marked it for deletion */
if (ioh->deleted) {
QLIST_REMOVE(ioh, next);
- qemu_free(ioh);
+ g_free(ioh);
}
}
}
@@ -157,7 +157,7 @@ static void sigchld_bh_handler(void *opaque)
QLIST_FOREACH_SAFE(rec, &child_watches, next, next) {
if (waitpid(rec->pid, NULL, WNOHANG) == rec->pid) {
QLIST_REMOVE(rec, next);
- qemu_free(rec);
+ g_free(rec);
}
}
}
@@ -185,7 +185,7 @@ int qemu_add_child_watch(pid_t pid)
return 1;
}
}
- rec = qemu_mallocz(sizeof(ChildProcessRecord));
+ rec = g_malloc0(sizeof(ChildProcessRecord));
rec->pid = pid;
QLIST_INSERT_HEAD(&child_watches, rec, next);
return 0;
diff --git a/kvm-all.c b/kvm-all.c
index b9c172b66..0ae2e2697 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -400,9 +400,9 @@ static int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
size = ALIGN(((mem->memory_size) >> TARGET_PAGE_BITS),
/*HOST_LONG_BITS*/ 64) / 8;
if (!d.dirty_bitmap) {
- d.dirty_bitmap = qemu_malloc(size);
+ d.dirty_bitmap = g_malloc(size);
} else if (size > allocated_size) {
- d.dirty_bitmap = qemu_realloc(d.dirty_bitmap, size);
+ d.dirty_bitmap = g_realloc(d.dirty_bitmap, size);
}
allocated_size = size;
memset(d.dirty_bitmap, 0, allocated_size);
@@ -419,7 +419,7 @@ static int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
mem->start_addr, mem->memory_size);
start_addr = mem->start_addr + mem->memory_size;
}
- qemu_free(d.dirty_bitmap);
+ g_free(d.dirty_bitmap);
return ret;
}
@@ -702,7 +702,7 @@ int kvm_init(void)
int ret;
int i;
- s = qemu_mallocz(sizeof(KVMState));
+ s = g_malloc0(sizeof(KVMState));
#ifdef KVM_CAP_SET_GUEST_DEBUG
QTAILQ_INIT(&s->kvm_sw_breakpoints);
@@ -804,7 +804,7 @@ err:
close(s->fd);
}
}
- qemu_free(s);
+ g_free(s);
return ret;
}
@@ -1188,7 +1188,7 @@ int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
return 0;
}
- bp = qemu_malloc(sizeof(struct kvm_sw_breakpoint));
+ bp = g_malloc(sizeof(struct kvm_sw_breakpoint));
if (!bp) {
return -ENOMEM;
}
@@ -1197,7 +1197,7 @@ int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
bp->use_count = 1;
err = kvm_arch_insert_sw_breakpoint(current_env, bp);
if (err) {
- qemu_free(bp);
+ g_free(bp);
return err;
}
@@ -1243,7 +1243,7 @@ int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr,
}
QTAILQ_REMOVE(&current_env->kvm_state->kvm_sw_breakpoints, bp, entry);
- qemu_free(bp);
+ g_free(bp);
} else {
err = kvm_arch_remove_hw_breakpoint(addr, len, type);
if (err) {
@@ -1316,12 +1316,12 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset)
return kvm_vcpu_ioctl(env, KVM_SET_SIGNAL_MASK, NULL);
}
- sigmask = qemu_malloc(sizeof(*sigmask) + sizeof(*sigset));
+ sigmask = g_malloc(sizeof(*sigmask) + sizeof(*sigset));
sigmask->len = 8;
memcpy(sigmask->sigset, sigset, sizeof(*sigset));
r = kvm_vcpu_ioctl(env, KVM_SET_SIGNAL_MASK, sigmask);
- qemu_free(sigmask);
+ g_free(sigmask);
return r;
}
diff --git a/libcacard/cac.c b/libcacard/cac.c
index f34f63ac7..f4b0b1b05 100644
--- a/libcacard/cac.c
+++ b/libcacard/cac.c
@@ -98,7 +98,7 @@ cac_applet_pki_reset(VCard *card, int channel)
pki_applet->cert_buffer = NULL;
if (pki_applet->sign_buffer) {
- qemu_free(pki_applet->sign_buffer);
+ g_free(pki_applet->sign_buffer);
pki_applet->sign_buffer = NULL;
}
pki_applet->cert_buffer_len = 0;
@@ -166,7 +166,7 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
sign_buffer = realloc(pki_applet->sign_buffer,
pki_applet->sign_buffer_len+size);
if (sign_buffer == NULL) {
- qemu_free(pki_applet->sign_buffer);
+ g_free(pki_applet->sign_buffer);
pki_applet->sign_buffer = NULL;
pki_applet->sign_buffer_len = 0;
*response = vcard_make_response(
@@ -204,7 +204,7 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
VCARD7816_STATUS_ERROR_P1_P2_INCORRECT);
break;
}
- qemu_free(sign_buffer);
+ g_free(sign_buffer);
pki_applet->sign_buffer = NULL;
pki_applet->sign_buffer_len = 0;
return VCARD_DONE;
@@ -271,15 +271,15 @@ cac_delete_pki_applet_private(VCardAppletPrivate *applet_private)
}
pki_applet_data = &(applet_private->u.pki_data);
if (pki_applet_data->cert != NULL) {
- qemu_free(pki_applet_data->cert);
+ g_free(pki_applet_data->cert);
}
if (pki_applet_data->sign_buffer != NULL) {
- qemu_free(pki_applet_data->sign_buffer);
+ g_free(pki_applet_data->sign_buffer);
}
if (pki_applet_data->key != NULL) {
vcard_emul_delete_key(pki_applet_data->key);
}
- qemu_free(applet_private);
+ g_free(applet_private);
}
static VCardAppletPrivate *
@@ -288,7 +288,7 @@ cac_new_pki_applet_private(const unsigned char *cert,
{
CACPKIAppletData *pki_applet_data = NULL;
VCardAppletPrivate *applet_private = NULL;
- applet_private = (VCardAppletPrivate *)qemu_malloc(sizeof(VCardAppletPrivate));
+ applet_private = (VCardAppletPrivate *)g_malloc(sizeof(VCardAppletPrivate));
pki_applet_data = &(applet_private->u.pki_data);
pki_applet_data->cert_buffer = NULL;
@@ -296,7 +296,7 @@ cac_new_pki_applet_private(const unsigned char *cert,
pki_applet_data->sign_buffer = NULL;
pki_applet_data->sign_buffer_len = 0;
pki_applet_data->key = NULL;
- pki_applet_data->cert = (unsigned char *)qemu_malloc(cert_len+1);
+ pki_applet_data->cert = (unsigned char *)g_malloc(cert_len+1);
/*
* if we want to support compression, then we simply change the 0 to a 1
* and compress the cert data with libz
diff --git a/libcacard/card_7816.c b/libcacard/card_7816.c
index eeea84989..9fd59d4a5 100644
--- a/libcacard/card_7816.c
+++ b/libcacard/card_7816.c
@@ -51,8 +51,8 @@ vcard_response_new_data(unsigned char *buf, int len)
{
VCardResponse *new_response;
- new_response = (VCardResponse *)qemu_malloc(sizeof(VCardResponse));
- new_response->b_data = qemu_malloc(len + 2);
+ new_response = (VCardResponse *)g_malloc(sizeof(VCardResponse));
+ new_response->b_data = g_malloc(len + 2);
memcpy(new_response->b_data, buf, len);
new_response->b_total_len = len+2;
new_response->b_len = len;
@@ -132,7 +132,7 @@ vcard_response_new_status(vcard_7816_status_t status)
{
VCardResponse *new_response;
- new_response = (VCardResponse *)qemu_malloc(sizeof(VCardResponse));
+ new_response = (VCardResponse *)g_malloc(sizeof(VCardResponse));
new_response->b_data = &new_response->b_sw1;
new_response->b_len = 0;
new_response->b_total_len = 2;
@@ -149,7 +149,7 @@ vcard_response_new_status_bytes(unsigned char sw1, unsigned char sw2)
{
VCardResponse *new_response;
- new_response = (VCardResponse *)qemu_malloc(sizeof(VCardResponse));
+ new_response = (VCardResponse *)g_malloc(sizeof(VCardResponse));
new_response->b_data = &new_response->b_sw1;
new_response->b_len = 0;
new_response->b_total_len = 2;
@@ -173,19 +173,19 @@ vcard_response_delete(VCardResponse *response)
case VCARD_MALLOC:
/* everything was malloc'ed */
if (response->b_data) {
- qemu_free(response->b_data);
+ g_free(response->b_data);
}
- qemu_free(response);
+ g_free(response);
break;
case VCARD_MALLOC_DATA:
/* only the data buffer was malloc'ed */
if (response->b_data) {
- qemu_free(response->b_data);
+ g_free(response->b_data);
}
break;
case VCARD_MALLOC_STRUCT:
/* only the structure was malloc'ed */
- qemu_free(response);
+ g_free(response);
break;
case VCARD_STATIC:
break;
@@ -336,18 +336,18 @@ vcard_apdu_new(unsigned char *raw_apdu, int len, vcard_7816_status_t *status)
return NULL;
}
- new_apdu = (VCardAPDU *)qemu_malloc(sizeof(VCardAPDU));
- new_apdu->a_data = qemu_malloc(len);
+ new_apdu = (VCardAPDU *)g_malloc(sizeof(VCardAPDU));
+ new_apdu->a_data = g_malloc(len);
memcpy(new_apdu->a_data, raw_apdu, len);
new_apdu->a_len = len;
*status = vcard_apdu_set_class(new_apdu);
if (*status != VCARD7816_STATUS_SUCCESS) {
- qemu_free(new_apdu);
+ g_free(new_apdu);
return NULL;
}
*status = vcard_apdu_set_length(new_apdu);
if (*status != VCARD7816_STATUS_SUCCESS) {
- qemu_free(new_apdu);
+ g_free(new_apdu);
new_apdu = NULL;
}
return new_apdu;
@@ -360,9 +360,9 @@ vcard_apdu_delete(VCardAPDU *apdu)
return;
}
if (apdu->a_data) {
- qemu_free(apdu->a_data);
+ g_free(apdu->a_data);
}
- qemu_free(apdu);
+ g_free(apdu);
}
diff --git a/libcacard/event.c b/libcacard/event.c
index bb2f9219f..61923761c 100644
--- a/libcacard/event.c
+++ b/libcacard/event.c
@@ -17,7 +17,7 @@ vevent_new(VEventType type, VReader *reader, VCard *card)
{
VEvent *new_vevent;
- new_vevent = (VEvent *)qemu_malloc(sizeof(VEvent));
+ new_vevent = (VEvent *)g_malloc(sizeof(VEvent));
new_vevent->next = NULL;
new_vevent->type = type;
new_vevent->reader = vreader_reference(reader);
@@ -34,7 +34,7 @@ vevent_delete(VEvent *vevent)
}
vreader_free(vevent->reader);
vcard_free(vevent->card);
- qemu_free(vevent);
+ g_free(vevent);
}
/*
diff --git a/libcacard/vcard.c b/libcacard/vcard.c
index 29b4cce6e..b02556ee0 100644
--- a/libcacard/vcard.c
+++ b/libcacard/vcard.c
@@ -37,8 +37,8 @@ vcard_buffer_response_new(unsigned char *buffer, int size)
{
VCardBufferResponse *new_buffer;
- new_buffer = (VCardBufferResponse *)qemu_malloc(sizeof(VCardBufferResponse));
- new_buffer->buffer = (unsigned char *)qemu_malloc(size);
+ new_buffer = (VCardBufferResponse *)g_malloc(sizeof(VCardBufferResponse));
+ new_buffer->buffer = (unsigned char *)g_malloc(size);
memcpy(new_buffer->buffer, buffer, size);
new_buffer->buffer_len = size;
new_buffer->current = new_buffer->buffer;
@@ -53,9 +53,9 @@ vcard_buffer_response_delete(VCardBufferResponse *buffer_response)
return;
}
if (buffer_response->buffer) {
- qemu_free(buffer_response->buffer);
+ g_free(buffer_response->buffer);
}
- qemu_free(buffer_response);
+ g_free(buffer_response);
}
@@ -102,14 +102,14 @@ vcard_new_applet(VCardProcessAPDU applet_process_function,
{
VCardApplet *applet;
- applet = (VCardApplet *)qemu_malloc(sizeof(VCardApplet));
+ applet = (VCardApplet *)g_malloc(sizeof(VCardApplet));
applet->next = NULL;
applet->applet_private = NULL;
applet->applet_private_free = NULL;
applet->process_apdu = applet_process_function;
applet->reset_applet = applet_reset_function;
- applet->aid = qemu_malloc(aid_len);
+ applet->aid = g_malloc(aid_len);
memcpy(applet->aid, aid, aid_len);
applet->aid_len = aid_len;
return applet;
@@ -127,10 +127,10 @@ vcard_delete_applet(VCardApplet *applet)
applet->applet_private = NULL;
}
if (applet->aid) {
- qemu_free(applet->aid);
+ g_free(applet->aid);
applet->aid = NULL;
}
- qemu_free(applet);
+ g_free(applet);
}
/* accessor */
@@ -151,7 +151,7 @@ vcard_new(VCardEmul *private, VCardEmulFree private_free)
VCard *new_card;
int i;
- new_card = (VCard *)qemu_malloc(sizeof(VCard));
+ new_card = (VCard *)g_malloc(sizeof(VCard));
new_card->applet_list = NULL;
for (i = 0; i < MAX_CHANNEL; i++) {
new_card->current_applet[i] = NULL;
@@ -199,7 +199,7 @@ vcard_free(VCard *vcard)
vcard_delete_applet(current_applet);
}
vcard_buffer_response_delete(vcard->vcard_buffer_response);
- qemu_free(vcard);
+ g_free(vcard);
return;
}
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 84fc49026..397485c75 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -94,9 +94,9 @@ vcard_emul_alloc_arrays(unsigned char ***certsp, int **cert_lenp,
*certsp = NULL;
*cert_lenp = NULL;
*keysp = NULL;
- *certsp = (unsigned char **)qemu_malloc(sizeof(unsigned char *)*cert_count);
- *cert_lenp = (int *)qemu_malloc(sizeof(int)*cert_count);
- *keysp = (VCardKey **)qemu_malloc(sizeof(VCardKey *)*cert_count);
+ *certsp = (unsigned char **)g_malloc(sizeof(unsigned char *)*cert_count);
+ *cert_lenp = (int *)g_malloc(sizeof(int)*cert_count);
+ *keysp = (VCardKey **)g_malloc(sizeof(VCardKey *)*cert_count);
return PR_TRUE;
}
@@ -140,7 +140,7 @@ vcard_emul_make_key(PK11SlotInfo *slot, CERTCertificate *cert)
{
VCardKey *key;
- key = (VCardKey *)qemu_malloc(sizeof(VCardKey));
+ key = (VCardKey *)g_malloc(sizeof(VCardKey));
key->slot = PK11_ReferenceSlot(slot);
key->cert = CERT_DupCertificate(cert);
/* NOTE: if we aren't logged into the token, this could return NULL */
@@ -244,7 +244,7 @@ vcard_emul_rsa_op(VCard *card, VCardKey *key,
/* be able to handle larger keys if necessariy */
bp = &buf[0];
if (sizeof(buf) < signature_len) {
- bp = qemu_malloc(signature_len);
+ bp = g_malloc(signature_len);
}
/*
@@ -348,7 +348,7 @@ vcard_emul_rsa_op(VCard *card, VCardKey *key,
key->failedX509 = VCardEmulTrue;
cleanup:
if (bp != buf) {
- qemu_free(bp);
+ g_free(bp);
}
return ret;
}
@@ -382,7 +382,7 @@ vcard_emul_login(VCard *card, unsigned char *pin, int pin_len)
* to handle multiple guests from one process, then we would need to keep
* a lot of extra state in our card structure
* */
- pin_string = qemu_malloc(pin_len+1);
+ pin_string = g_malloc(pin_len+1);
memcpy(pin_string, pin, pin_len);
pin_string[pin_len] = 0;
@@ -394,7 +394,7 @@ vcard_emul_login(VCard *card, unsigned char *pin, int pin_len)
rv = PK11_Authenticate(slot, PR_FALSE, pin_string);
memset(pin_string, 0, pin_len); /* don't let the pin hang around in memory
to be snooped */
- qemu_free(pin_string);
+ g_free(pin_string);
if (rv == SECSuccess) {
return VCARD7816_STATUS_SUCCESS;
}
@@ -452,7 +452,7 @@ vreader_emul_new(PK11SlotInfo *slot, VCardEmulType type, const char *params)
{
VReaderEmul *new_reader_emul;
- new_reader_emul = (VReaderEmul *)qemu_malloc(sizeof(VReaderEmul));
+ new_reader_emul = (VReaderEmul *)g_malloc(sizeof(VReaderEmul));
new_reader_emul->slot = PK11_ReferenceSlot(slot);
new_reader_emul->default_type = type;
@@ -473,9 +473,9 @@ vreader_emul_delete(VReaderEmul *vreader_emul)
PK11_FreeSlot(vreader_emul->slot);
}
if (vreader_emul->type_params) {
- qemu_free(vreader_emul->type_params);
+ g_free(vreader_emul->type_params);
}
- qemu_free(vreader_emul);
+ g_free(vreader_emul);
}
/*
@@ -658,9 +658,9 @@ vcard_emul_mirror_card(VReader *vreader)
/* now create the card */
card = vcard_emul_make_card(vreader, certs, cert_len, keys, cert_count);
- qemu_free(certs);
- qemu_free(cert_len);
- qemu_free(keys);
+ g_free(certs);
+ g_free(cert_len);
+ g_free(keys);
return card;
}
@@ -947,9 +947,9 @@ vcard_emul_init(const VCardEmulOptions *options)
vreader_free(vreader);
has_readers = PR_TRUE;
}
- qemu_free(certs);
- qemu_free(cert_len);
- qemu_free(keys);
+ g_free(certs);
+ g_free(cert_len);
+ g_free(keys);
}
/* if we aren't suppose to use hw, skip looking up hardware tokens */
@@ -1173,18 +1173,18 @@ vcard_emul_options(const char *args)
}
opts->vreader = vreaderOpt;
vreaderOpt = &vreaderOpt[opts->vreader_count];
- vreaderOpt->name = qemu_strndup(name, name_length);
- vreaderOpt->vname = qemu_strndup(vname, vname_length);
+ vreaderOpt->name = g_strndup(name, name_length);
+ vreaderOpt->vname = g_strndup(vname, vname_length);
vreaderOpt->card_type = type;
vreaderOpt->type_params =
- qemu_strndup(type_params, type_params_length);
+ g_strndup(type_params, type_params_length);
count = count_tokens(args, ',', ')') + 1;
vreaderOpt->cert_count = count;
- vreaderOpt->cert_name = (char **)qemu_malloc(count*sizeof(char *));
+ vreaderOpt->cert_name = (char **)g_malloc(count*sizeof(char *));
for (i = 0; i < count; i++) {
const char *cert = args;
args = strpbrk(args, ",)");
- vreaderOpt->cert_name[i] = qemu_strndup(cert, args - cert);
+ vreaderOpt->cert_name[i] = g_strndup(cert, args - cert);
args = strip(args+1);
}
if (*args == ')') {
@@ -1211,7 +1211,7 @@ vcard_emul_options(const char *args)
args = strip(args+10);
params = args;
args = find_blank(args);
- opts->hw_type_params = qemu_strndup(params, args-params);
+ opts->hw_type_params = g_strndup(params, args-params);
/* db="/data/base/path" */
} else if (strncmp(args, "db=", 3) == 0) {
const char *db;
@@ -1222,7 +1222,7 @@ vcard_emul_options(const char *args)
args++;
db = args;
args = strpbrk(args, "\"\n");
- opts->nss_db = qemu_strndup(db, args-db);
+ opts->nss_db = g_strndup(db, args-db);
if (*args != 0) {
args++;
}
diff --git a/libcacard/vreader.c b/libcacard/vreader.c
index 4a0125b0e..ec126dfa4 100644
--- a/libcacard/vreader.c
+++ b/libcacard/vreader.c
@@ -46,7 +46,7 @@ vreader_new(const char *name, VReaderEmul *private,
{
VReader *reader;
- reader = (VReader *)qemu_malloc(sizeof(VReader));
+ reader = (VReader *)g_malloc(sizeof(VReader));
qemu_mutex_init(&reader->lock);
reader->reference_count = 1;
reader->name = name ? strdup(name) : NULL;
@@ -87,12 +87,12 @@ vreader_free(VReader *reader)
vcard_free(reader->card);
}
if (reader->name) {
- qemu_free(reader->name);
+ g_free(reader->name);
}
if (reader->reader_private_free) {
reader->reader_private_free(reader->reader_private);
}
- qemu_free(reader);
+ g_free(reader);
return;
}
@@ -237,7 +237,7 @@ vreader_list_entry_new(VReader *reader)
VReaderListEntry *new_reader_list_entry;
new_reader_list_entry = (VReaderListEntry *)
- qemu_malloc(sizeof(VReaderListEntry));
+ g_malloc(sizeof(VReaderListEntry));
new_reader_list_entry->next = NULL;
new_reader_list_entry->prev = NULL;
new_reader_list_entry->reader = vreader_reference(reader);
@@ -251,7 +251,7 @@ vreader_list_entry_delete(VReaderListEntry *entry)
return;
}
vreader_free(entry->reader);
- qemu_free(entry);
+ g_free(entry);
}
@@ -260,7 +260,7 @@ vreader_list_new(void)
{
VReaderList *new_reader_list;
- new_reader_list = (VReaderList *)qemu_malloc(sizeof(VReaderList));
+ new_reader_list = (VReaderList *)g_malloc(sizeof(VReaderList));
new_reader_list->head = NULL;
new_reader_list->tail = NULL;
return new_reader_list;
@@ -278,7 +278,7 @@ vreader_list_delete(VReaderList *list)
}
list->head = NULL;
list->tail = NULL;
- qemu_free(list);
+ g_free(list);
}
diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
index ce33f5a92..a7b38340d 100644
--- a/libcacard/vscclient.c
+++ b/libcacard/vscclient.c
@@ -488,7 +488,7 @@ main(
for (i = 0; i < cert_count; i++) {
len += strlen(cert_names[i])+1; /* 1 == comma */
}
- new_args = qemu_malloc(len);
+ new_args = g_malloc(len);
strcpy(new_args, emul_args);
strcat(new_args, SOFT_STRING);
for (i = 0; i < cert_count; i++) {
diff --git a/linux-aio.c b/linux-aio.c
index dc3faf249..5fd39327b 100644
--- a/linux-aio.c
+++ b/linux-aio.c
@@ -204,7 +204,7 @@ void *laio_init(void)
{
struct qemu_laio_state *s;
- s = qemu_mallocz(sizeof(*s));
+ s = g_malloc0(sizeof(*s));
s->efd = eventfd(0, 0);
if (s->efd == -1)
goto out_free_state;
@@ -221,6 +221,6 @@ void *laio_init(void)
out_close_efd:
close(s->efd);
out_free_state:
- qemu_free(s);
+ g_free(s);
return NULL;
}
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 443d246ad..04e8e6e06 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1473,7 +1473,7 @@ static void load_elf_image(const char *image_name, int image_fd,
#ifdef CONFIG_USE_FDPIC
{
struct elf32_fdpic_loadseg *loadsegs = info->loadsegs =
- qemu_malloc(sizeof(*loadsegs) * info->nsegs);
+ g_malloc(sizeof(*loadsegs) * info->nsegs);
for (i = 0; i < ehdr->e_phnum; ++i) {
switch (phdr[i].p_type) {
@@ -2063,7 +2063,7 @@ static struct mm_struct *vma_init(void)
{
struct mm_struct *mm;
- if ((mm = qemu_malloc(sizeof (*mm))) == NULL)
+ if ((mm = g_malloc(sizeof (*mm))) == NULL)
return (NULL);
mm->mm_count = 0;
@@ -2078,9 +2078,9 @@ static void vma_delete(struct mm_struct *mm)
while ((vma = vma_first(mm)) != NULL) {
QTAILQ_REMOVE(&mm->mm_mmap, vma, vma_link);
- qemu_free(vma);
+ g_free(vma);
}
- qemu_free(mm);
+ g_free(mm);
}
static int vma_add_mapping(struct mm_struct *mm, abi_ulong start,
@@ -2088,7 +2088,7 @@ static int vma_add_mapping(struct mm_struct *mm, abi_ulong start,
{
struct vm_area_struct *vma;
- if ((vma = qemu_mallocz(sizeof (*vma))) == NULL)
+ if ((vma = g_malloc0(sizeof (*vma))) == NULL)
return (-1);
vma->vma_start = start;
@@ -2412,7 +2412,7 @@ static void fill_thread_info(struct elf_note_info *info, const CPUState *env)
TaskState *ts = (TaskState *)env->opaque;
struct elf_thread_status *ets;
- ets = qemu_mallocz(sizeof (*ets));
+ ets = g_malloc0(sizeof (*ets));
ets->num_notes = 1; /* only prstatus is dumped */
fill_prstatus(&ets->prstatus, ts, 0);
elf_core_copy_regs(&ets->prstatus.pr_reg, env);
@@ -2436,13 +2436,13 @@ static int fill_note_info(struct elf_note_info *info,
QTAILQ_INIT(&info->thread_list);
- info->notes = qemu_mallocz(NUMNOTES * sizeof (struct memelfnote));
+ info->notes = g_malloc0(NUMNOTES * sizeof (struct memelfnote));
if (info->notes == NULL)
return (-ENOMEM);
- info->prstatus = qemu_mallocz(sizeof (*info->prstatus));
+ info->prstatus = g_malloc0(sizeof (*info->prstatus));
if (info->prstatus == NULL)
return (-ENOMEM);
- info->psinfo = qemu_mallocz(sizeof (*info->psinfo));
+ info->psinfo = g_malloc0(sizeof (*info->psinfo));
if (info->prstatus == NULL)
return (-ENOMEM);
@@ -2483,12 +2483,12 @@ static void free_note_info(struct elf_note_info *info)
while (!QTAILQ_EMPTY(&info->thread_list)) {
ets = QTAILQ_FIRST(&info->thread_list);
QTAILQ_REMOVE(&info->thread_list, ets, ets_link);
- qemu_free(ets);
+ g_free(ets);
}
- qemu_free(info->prstatus);
- qemu_free(info->psinfo);
- qemu_free(info->notes);
+ g_free(info->prstatus);
+ g_free(info->psinfo);
+ g_free(info->notes);
}
static int write_note_info(struct elf_note_info *info, int fd)
diff --git a/linux-user/main.c b/linux-user/main.c
index 8e1547432..95e3fe66c 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3216,7 +3216,7 @@ int main(int argc, char **argv, char **envp)
}
target_argv[target_argc] = NULL;
- ts = qemu_mallocz (sizeof(TaskState));
+ ts = g_malloc0 (sizeof(TaskState));
init_task_state(ts);
/* build Task State */
ts->info = info;
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 73f9baa6f..6bdf4e6ab 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3991,7 +3991,7 @@ static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp,
new_thread_info info;
pthread_attr_t attr;
#endif
- ts = qemu_mallocz(sizeof(TaskState));
+ ts = g_malloc0(sizeof(TaskState));
init_task_state(ts);
/* we create a new CPU instance. */
new_env = cpu_copy(env);
@@ -4057,7 +4057,7 @@ static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp,
if (flags & CLONE_NPTL_FLAGS2)
return -EINVAL;
/* This is probably going to die very quickly, but do it anyway. */
- new_stack = qemu_mallocz (NEW_STACK_SIZE);
+ new_stack = g_malloc0 (NEW_STACK_SIZE);
#ifdef __ia64__
ret = __clone2(clone_func, new_stack, NEW_STACK_SIZE, flags, new_env);
#else
@@ -4651,8 +4651,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
NULL, NULL, 0);
}
thread_env = NULL;
- qemu_free(cpu_env);
- qemu_free(ts);
+ g_free(cpu_env);
+ g_free(ts);
pthread_exit(NULL);
}
#endif
diff --git a/memory.c b/memory.c
index beff98c35..24439f386 100644
--- a/memory.c
+++ b/memory.c
@@ -183,7 +183,7 @@ static void flatview_insert(FlatView *view, unsigned pos, FlatRange *range)
{
if (view->nr == view->nr_allocated) {
view->nr_allocated = MAX(2 * view->nr, 10);
- view->ranges = qemu_realloc(view->ranges,
+ view->ranges = g_realloc(view->ranges,
view->nr_allocated * sizeof(*view->ranges));
}
memmove(view->ranges + pos + 1, view->ranges + pos,
@@ -194,7 +194,7 @@ static void flatview_insert(FlatView *view, unsigned pos, FlatRange *range)
static void flatview_destroy(FlatView *view)
{
- qemu_free(view->ranges);
+ g_free(view->ranges);
}
static bool can_merge(FlatRange *r1, FlatRange *r2)
@@ -553,7 +553,7 @@ static void address_space_update_ioeventfds(AddressSpace *as)
fr->addr.start - fr->offset_in_region);
if (addrrange_intersects(fr->addr, tmp)) {
++ioeventfd_nb;
- ioeventfds = qemu_realloc(ioeventfds,
+ ioeventfds = g_realloc(ioeventfds,
ioeventfd_nb * sizeof(*ioeventfds));
ioeventfds[ioeventfd_nb-1] = fr->mr->ioeventfds[i];
ioeventfds[ioeventfd_nb-1].addr = tmp;
@@ -564,7 +564,7 @@ static void address_space_update_ioeventfds(AddressSpace *as)
address_space_add_del_ioeventfds(as, ioeventfds, ioeventfd_nb,
as->ioeventfds, as->ioeventfd_nb);
- qemu_free(as->ioeventfds);
+ g_free(as->ioeventfds);
as->ioeventfds = ioeventfds;
as->ioeventfd_nb = ioeventfd_nb;
}
@@ -713,7 +713,7 @@ void memory_region_init(MemoryRegion *mr,
QTAILQ_INIT(&mr->subregions);
memset(&mr->subregions_link, 0, sizeof mr->subregions_link);
QTAILQ_INIT(&mr->coalesced);
- mr->name = qemu_strdup(name);
+ mr->name = g_strdup(name);
mr->dirty_log_mask = 0;
mr->ioeventfd_nb = 0;
mr->ioeventfds = NULL;
@@ -949,8 +949,8 @@ void memory_region_destroy(MemoryRegion *mr)
assert(QTAILQ_EMPTY(&mr->subregions));
mr->destructor(mr);
memory_region_clear_coalescing(mr);
- qemu_free((char *)mr->name);
- qemu_free(mr->ioeventfds);
+ g_free((char *)mr->name);
+ g_free(mr->ioeventfds);
}
uint64_t memory_region_size(MemoryRegion *mr)
@@ -1061,7 +1061,7 @@ void memory_region_add_coalescing(MemoryRegion *mr,
target_phys_addr_t offset,
uint64_t size)
{
- CoalescedMemoryRange *cmr = qemu_malloc(sizeof(*cmr));
+ CoalescedMemoryRange *cmr = g_malloc(sizeof(*cmr));
cmr->addr = addrrange_make(offset, size);
QTAILQ_INSERT_TAIL(&mr->coalesced, cmr, link);
@@ -1075,7 +1075,7 @@ void memory_region_clear_coalescing(MemoryRegion *mr)
while (!QTAILQ_EMPTY(&mr->coalesced)) {
cmr = QTAILQ_FIRST(&mr->coalesced);
QTAILQ_REMOVE(&mr->coalesced, cmr, link);
- qemu_free(cmr);
+ g_free(cmr);
}
memory_region_update_coalesced_range(mr);
}
@@ -1102,7 +1102,7 @@ void memory_region_add_eventfd(MemoryRegion *mr,
}
}
++mr->ioeventfd_nb;
- mr->ioeventfds = qemu_realloc(mr->ioeventfds,
+ mr->ioeventfds = g_realloc(mr->ioeventfds,
sizeof(*mr->ioeventfds) * mr->ioeventfd_nb);
memmove(&mr->ioeventfds[i+1], &mr->ioeventfds[i],
sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb-1 - i));
@@ -1135,7 +1135,7 @@ void memory_region_del_eventfd(MemoryRegion *mr,
memmove(&mr->ioeventfds[i], &mr->ioeventfds[i+1],
sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb - (i+1)));
--mr->ioeventfd_nb;
- mr->ioeventfds = qemu_realloc(mr->ioeventfds,
+ mr->ioeventfds = g_realloc(mr->ioeventfds,
sizeof(*mr->ioeventfds)*mr->ioeventfd_nb + 1);
memory_region_update_topology();
}
diff --git a/migration-exec.c b/migration-exec.c
index 4b7aad8b6..2cfb6f232 100644
--- a/migration-exec.c
+++ b/migration-exec.c
@@ -71,7 +71,7 @@ MigrationState *exec_start_outgoing_migration(Monitor *mon,
FdMigrationState *s;
FILE *f;
- s = qemu_mallocz(sizeof(*s));
+ s = g_malloc0(sizeof(*s));
f = popen(command, "w");
if (f == NULL) {
@@ -113,7 +113,7 @@ MigrationState *exec_start_outgoing_migration(Monitor *mon,
err_after_open:
pclose(f);
err_after_alloc:
- qemu_free(s);
+ g_free(s);
return NULL;
}
diff --git a/migration-fd.c b/migration-fd.c
index 66d51c1cc..aee690aae 100644
--- a/migration-fd.c
+++ b/migration-fd.c
@@ -59,7 +59,7 @@ MigrationState *fd_start_outgoing_migration(Monitor *mon,
{
FdMigrationState *s;
- s = qemu_mallocz(sizeof(*s));
+ s = g_malloc0(sizeof(*s));
s->fd = monitor_get_fd(mon, fdname);
if (s->fd == -1) {
@@ -96,7 +96,7 @@ MigrationState *fd_start_outgoing_migration(Monitor *mon,
err_after_open:
close(s->fd);
err_after_alloc:
- qemu_free(s);
+ g_free(s);
return NULL;
}
diff --git a/migration-tcp.c b/migration-tcp.c
index d3d80c970..c431e03a4 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -89,7 +89,7 @@ MigrationState *tcp_start_outgoing_migration(Monitor *mon,
if (parse_host_port(&addr, host_port) < 0)
return NULL;
- s = qemu_mallocz(sizeof(*s));
+ s = g_malloc0(sizeof(*s));
s->get_error = socket_errno;
s->write = socket_write;
@@ -106,7 +106,7 @@ MigrationState *tcp_start_outgoing_migration(Monitor *mon,
s->bandwidth_limit = bandwidth_limit;
s->fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
if (s->fd == -1) {
- qemu_free(s);
+ g_free(s);
return NULL;
}
diff --git a/migration-unix.c b/migration-unix.c
index c8625c7f6..6dc985d42 100644
--- a/migration-unix.c
+++ b/migration-unix.c
@@ -88,7 +88,7 @@ MigrationState *unix_start_outgoing_migration(Monitor *mon,
addr.sun_family = AF_UNIX;
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", path);
- s = qemu_mallocz(sizeof(*s));
+ s = g_malloc0(sizeof(*s));
s->get_error = unix_errno;
s->write = unix_write;
@@ -138,7 +138,7 @@ err_after_open:
close(s->fd);
err_after_alloc:
- qemu_free(s);
+ g_free(s);
return NULL;
}
diff --git a/migration.c b/migration.c
index 756fa6261..f5959b439 100644
--- a/migration.c
+++ b/migration.c
@@ -428,7 +428,7 @@ void migrate_fd_release(MigrationState *mig_state)
notifier_list_notify(&migration_state_notifiers, NULL);
migrate_fd_cleanup(s);
}
- qemu_free(s);
+ g_free(s);
}
void migrate_fd_wait_for_unfreeze(void *opaque)
diff --git a/module.c b/module.c
index e77d56976..91f0e61cb 100644
--- a/module.c
+++ b/module.c
@@ -59,7 +59,7 @@ void register_module_init(void (*fn)(void), module_init_type type)
ModuleEntry *e;
ModuleTypeList *l;
- e = qemu_mallocz(sizeof(*e));
+ e = g_malloc0(sizeof(*e));
e->init = fn;
l = find_type(type);
diff --git a/monitor.c b/monitor.c
index 1b8ba2c1f..68553f1f3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -636,7 +636,7 @@ static void user_monitor_complete(void *opaque, QObject *ret_data)
data->user_print(data->mon, ret_data);
}
monitor_resume(data->mon);
- qemu_free(data);
+ g_free(data);
}
static void qmp_monitor_complete(void *opaque, QObject *ret_data)
@@ -660,7 +660,7 @@ static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,
{
int ret;
- MonitorCompletionData *cb_data = qemu_malloc(sizeof(*cb_data));
+ MonitorCompletionData *cb_data = g_malloc(sizeof(*cb_data));
cb_data->mon = mon;
cb_data->user_print = cmd->user_print;
monitor_suspend(mon);
@@ -668,7 +668,7 @@ static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,
user_monitor_complete, cb_data);
if (ret < 0) {
monitor_resume(mon);
- qemu_free(cb_data);
+ g_free(cb_data);
}
}
@@ -676,14 +676,14 @@ static void user_async_info_handler(Monitor *mon, const mon_cmd_t *cmd)
{
int ret;
- MonitorCompletionData *cb_data = qemu_malloc(sizeof(*cb_data));
+ MonitorCompletionData *cb_data = g_malloc(sizeof(*cb_data));
cb_data->mon = mon;
cb_data->user_print = cmd->user_print;
monitor_suspend(mon);
ret = cmd->mhandler.info_async(mon, user_monitor_complete, cb_data);
if (ret < 0) {
monitor_resume(mon);
- qemu_free(cb_data);
+ g_free(cb_data);
}
}
@@ -2545,7 +2545,7 @@ static void do_stop_capture(Monitor *mon, const QDict *qdict)
if (i == n) {
s->ops.destroy (s->opaque);
QLIST_REMOVE (s, entries);
- qemu_free (s);
+ g_free (s);
return;
}
}
@@ -2562,7 +2562,7 @@ static void do_wav_capture(Monitor *mon, const QDict *qdict)
int nchannels = qdict_get_try_int(qdict, "nchannels", -1);
CaptureState *s;
- s = qemu_mallocz (sizeof (*s));
+ s = g_malloc0 (sizeof (*s));
freq = has_freq ? freq : 44100;
bits = has_bits ? bits : 16;
@@ -2570,7 +2570,7 @@ static void do_wav_capture(Monitor *mon, const QDict *qdict)
if (wav_start_capture (s, path, freq, bits, nchannels)) {
monitor_printf(mon, "Failed to add wave capture\n");
- qemu_free (s);
+ g_free (s);
return;
}
QLIST_INSERT_HEAD (&capture_head, s, entries);
@@ -2780,8 +2780,8 @@ static int do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)
return 0;
}
- monfd = qemu_mallocz(sizeof(mon_fd_t));
- monfd->name = qemu_strdup(fdname);
+ monfd = g_malloc0(sizeof(mon_fd_t));
+ monfd->name = g_strdup(fdname);
monfd->fd = fd;
QLIST_INSERT_HEAD(&mon->fds, monfd, next);
@@ -2800,8 +2800,8 @@ static int do_closefd(Monitor *mon, const QDict *qdict, QObject **ret_data)
QLIST_REMOVE(monfd, next);
close(monfd->fd);
- qemu_free(monfd->name);
- qemu_free(monfd);
+ g_free(monfd->name);
+ g_free(monfd);
return 0;
}
@@ -2836,8 +2836,8 @@ int monitor_get_fd(Monitor *mon, const char *fdname)
/* caller takes ownership of fd */
QLIST_REMOVE(monfd, next);
- qemu_free(monfd->name);
- qemu_free(monfd);
+ g_free(monfd->name);
+ g_free(monfd);
return fd;
}
@@ -4034,7 +4034,7 @@ static char *key_get_info(const char *type, char **key)
}
len = p - type;
- str = qemu_malloc(len + 1);
+ str = g_malloc(len + 1);
memcpy(str, type, len);
str[len] = '\0';
@@ -4417,7 +4417,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
monitor_printf(mon, "%s: unknown type '%c'\n", cmdname, c);
goto fail;
}
- qemu_free(key);
+ g_free(key);
key = NULL;
}
/* check that all arguments were parsed */
@@ -4432,7 +4432,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
return cmd;
fail:
- qemu_free(key);
+ g_free(key);
return NULL;
}
@@ -4631,7 +4631,7 @@ static void parse_cmdline(const char *cmdline,
if (nb_args >= MAX_ARGS)
break;
ret = get_str(buf, sizeof(buf), &p);
- args[nb_args] = qemu_strdup(buf);
+ args[nb_args] = g_strdup(buf);
nb_args++;
if (ret < 0)
break;
@@ -4668,7 +4668,7 @@ static void monitor_find_completion(const char *cmdline)
if (nb_args >= MAX_ARGS) {
goto cleanup;
}
- args[nb_args++] = qemu_strdup("");
+ args[nb_args++] = g_strdup("");
}
if (nb_args <= 1) {
/* command completion */
@@ -4743,7 +4743,7 @@ static void monitor_find_completion(const char *cmdline)
cleanup:
for (i = 0; i < nb_args; i++) {
- qemu_free(args[i]);
+ g_free(args[i]);
}
}
@@ -5261,7 +5261,7 @@ void monitor_init(CharDriverState *chr, int flags)
is_first_init = 0;
}
- mon = qemu_mallocz(sizeof(*mon));
+ mon = g_malloc0(sizeof(*mon));
mon->chr = chr;
mon->flags = flags;
@@ -5271,7 +5271,7 @@ void monitor_init(CharDriverState *chr, int flags)
}
if (monitor_ctrl_mode(mon)) {
- mon->mc = qemu_mallocz(sizeof(MonitorControl));
+ mon->mc = g_malloc0(sizeof(MonitorControl));
/* Control mode requires special handlers */
qemu_chr_add_handlers(chr, monitor_can_read, monitor_control_read,
monitor_control_event, mon);
diff --git a/net.c b/net.c
index cb6a2b03d..d05930c91 100644
--- a/net.c
+++ b/net.c
@@ -170,7 +170,7 @@ static char *assign_name(VLANClientState *vc1, const char *model)
snprintf(buf, sizeof(buf), "%s.%d", model, id);
- return qemu_strdup(buf);
+ return g_strdup(buf);
}
static ssize_t qemu_deliver_packet(VLANClientState *sender,
@@ -194,12 +194,12 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info,
assert(info->size >= sizeof(VLANClientState));
- vc = qemu_mallocz(info->size);
+ vc = g_malloc0(info->size);
vc->info = info;
- vc->model = qemu_strdup(model);
+ vc->model = g_strdup(model);
if (name) {
- vc->name = qemu_strdup(name);
+ vc->name = g_strdup(name);
} else {
vc->name = assign_name(vc, model);
}
@@ -268,9 +268,9 @@ static void qemu_free_vlan_client(VLANClientState *vc)
vc->peer->peer = NULL;
}
}
- qemu_free(vc->name);
- qemu_free(vc->model);
- qemu_free(vc);
+ g_free(vc->name);
+ g_free(vc->model);
+ g_free(vc);
}
void qemu_del_vlan_client(VLANClientState *vc)
@@ -640,7 +640,7 @@ VLANState *qemu_find_vlan(int id, int allocate)
return NULL;
}
- vlan = qemu_mallocz(sizeof(VLANState));
+ vlan = g_malloc0(sizeof(VLANState));
vlan->id = id;
QTAILQ_INIT(&vlan->clients);
@@ -710,7 +710,7 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models,
int i;
if (!nd->model)
- nd->model = qemu_strdup(default_model);
+ nd->model = g_strdup(default_model);
for (i = 0 ; models[i]; i++) {
if (strcmp(nd->model, models[i]) == 0)
@@ -774,13 +774,13 @@ static int net_init_nic(QemuOpts *opts,
nd->vlan = vlan;
}
if (name) {
- nd->name = qemu_strdup(name);
+ nd->name = g_strdup(name);
}
if (qemu_opt_get(opts, "model")) {
- nd->model = qemu_strdup(qemu_opt_get(opts, "model"));
+ nd->model = g_strdup(qemu_opt_get(opts, "model"));
}
if (qemu_opt_get(opts, "addr")) {
- nd->devaddr = qemu_strdup(qemu_opt_get(opts, "addr"));
+ nd->devaddr = g_strdup(qemu_opt_get(opts, "addr"));
}
if (qemu_opt_get(opts, "macaddr") &&
diff --git a/net/queue.c b/net/queue.c
index 2ea6cd0b6..1ab5247a3 100644
--- a/net/queue.c
+++ b/net/queue.c
@@ -63,7 +63,7 @@ NetQueue *qemu_new_net_queue(NetPacketDeliver *deliver,
{
NetQueue *queue;
- queue = qemu_mallocz(sizeof(NetQueue));
+ queue = g_malloc0(sizeof(NetQueue));
queue->deliver = deliver;
queue->deliver_iov = deliver_iov;
@@ -82,10 +82,10 @@ void qemu_del_net_queue(NetQueue *queue)
QTAILQ_FOREACH_SAFE(packet, &queue->packets, entry, next) {
QTAILQ_REMOVE(&queue->packets, packet, entry);
- qemu_free(packet);
+ g_free(packet);
}
- qemu_free(queue);
+ g_free(queue);
}
static ssize_t qemu_net_queue_append(NetQueue *queue,
@@ -97,7 +97,7 @@ static ssize_t qemu_net_queue_append(NetQueue *queue,
{
NetPacket *packet;
- packet = qemu_malloc(sizeof(NetPacket) + size);
+ packet = g_malloc(sizeof(NetPacket) + size);
packet->sender = sender;
packet->flags = flags;
packet->size = size;
@@ -124,7 +124,7 @@ static ssize_t qemu_net_queue_append_iov(NetQueue *queue,
max_len += iov[i].iov_len;
}
- packet = qemu_malloc(sizeof(NetPacket) + max_len);
+ packet = g_malloc(sizeof(NetPacket) + max_len);
packet->sender = sender;
packet->sent_cb = sent_cb;
packet->flags = flags;
@@ -227,7 +227,7 @@ void qemu_net_queue_purge(NetQueue *queue, VLANClientState *from)
QTAILQ_FOREACH_SAFE(packet, &queue->packets, entry, next) {
if (packet->sender == from) {
QTAILQ_REMOVE(&queue->packets, packet, entry);
- qemu_free(packet);
+ g_free(packet);
}
}
}
@@ -255,6 +255,6 @@ void qemu_net_queue_flush(NetQueue *queue)
packet->sent_cb(packet->sender, ret);
}
- qemu_free(packet);
+ g_free(packet);
}
}
diff --git a/net/slirp.c b/net/slirp.c
index 157b80a9f..ec7433fea 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -450,7 +450,7 @@ int net_slirp_redir(const char *redir_str)
struct slirp_config_str *config;
if (QTAILQ_EMPTY(&slirp_stacks)) {
- config = qemu_malloc(sizeof(*config));
+ config = g_malloc(sizeof(*config));
pstrcpy(config->str, sizeof(config->str), redir_str);
config->flags = SLIRP_CFG_HOSTFWD | SLIRP_CFG_LEGACY;
config->next = slirp_configs;
@@ -614,19 +614,19 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str,
goto fail_syntax;
}
- fwd = qemu_malloc(sizeof(struct GuestFwd));
+ fwd = g_malloc(sizeof(struct GuestFwd));
snprintf(buf, sizeof(buf), "guestfwd.tcp.%d", port);
fwd->hd = qemu_chr_open(buf, p, NULL);
if (!fwd->hd) {
error_report("could not open guest forwarding device '%s'", buf);
- qemu_free(fwd);
+ g_free(fwd);
return -1;
}
if (slirp_add_exec(s->slirp, 3, fwd->hd, &server, port) < 0) {
error_report("conflicting/invalid host:port in guest forwarding "
"rule '%s'", config_str);
- qemu_free(fwd);
+ g_free(fwd);
return -1;
}
fwd->server = server;
@@ -662,7 +662,7 @@ static int net_init_slirp_configs(const char *name, const char *value, void *opa
return 0;
}
- config = qemu_mallocz(sizeof(*config));
+ config = g_malloc0(sizeof(*config));
pstrcpy(config->str, sizeof(config->str), value);
@@ -720,7 +720,7 @@ int net_init_slirp(QemuOpts *opts,
const char *ip = qemu_opt_get(opts, "ip");
int l = strlen(ip) + strlen("/24") + 1;
- vnet = qemu_malloc(l);
+ vnet = g_malloc(l);
/* emulate legacy ip= parameter */
pstrcpy(vnet, l, ip);
@@ -729,9 +729,9 @@ int net_init_slirp(QemuOpts *opts,
if (qemu_opt_get(opts, "net")) {
if (vnet) {
- qemu_free(vnet);
+ g_free(vnet);
}
- vnet = qemu_strdup(qemu_opt_get(opts, "net"));
+ vnet = g_strdup(qemu_opt_get(opts, "net"));
}
qemu_opt_foreach(opts, net_init_slirp_configs, NULL, 0);
@@ -743,10 +743,10 @@ int net_init_slirp(QemuOpts *opts,
while (slirp_configs) {
config = slirp_configs;
slirp_configs = config->next;
- qemu_free(config);
+ g_free(config);
}
- qemu_free(vnet);
+ g_free(vnet);
return ret;
}
@@ -764,7 +764,7 @@ int net_slirp_parse_legacy(QemuOptsList *opts_list, const char *optarg, int *ret
if (QTAILQ_EMPTY(&slirp_stacks)) {
struct slirp_config_str *config;
- config = qemu_malloc(sizeof(*config));
+ config = g_malloc(sizeof(*config));
pstrcpy(config->str, sizeof(config->str), optarg);
config->flags = SLIRP_CFG_LEGACY;
config->next = slirp_configs;
diff --git a/net/socket.c b/net/socket.c
index 5cd0b9abf..e9ef12877 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -404,7 +404,7 @@ static int net_socket_listen_init(VLANState *vlan,
if (parse_host_port(&saddr, host_str) < 0)
return -1;
- s = qemu_mallocz(sizeof(NetSocketListenState));
+ s = g_malloc0(sizeof(NetSocketListenState));
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0) {
@@ -428,8 +428,8 @@ static int net_socket_listen_init(VLANState *vlan,
return -1;
}
s->vlan = vlan;
- s->model = qemu_strdup(model);
- s->name = name ? qemu_strdup(name) : NULL;
+ s->model = g_strdup(model);
+ s->name = name ? g_strdup(name) : NULL;
s->fd = fd;
qemu_set_fd_handler(fd, net_socket_accept, NULL, s);
return 0;
diff --git a/os-posix.c b/os-posix.c
index 6f8d4886e..dbf3b240f 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -128,12 +128,12 @@ char *os_find_datadir(const char *argv0)
max_len = strlen(dir) +
MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1;
- res = qemu_mallocz(max_len);
+ res = g_malloc0(max_len);
snprintf(res, max_len, "%s%s", dir, SHARE_SUFFIX);
if (access(res, R_OK)) {
snprintf(res, max_len, "%s%s", dir, BUILD_SUFFIX);
if (access(res, R_OK)) {
- qemu_free(res);
+ g_free(res);
res = NULL;
}
}
diff --git a/os-win32.c b/os-win32.c
index b6652af7f..d3cea42a5 100644
--- a/os-win32.c
+++ b/os-win32.c
@@ -41,7 +41,7 @@ int setenv(const char *name, const char *value, int overwrite)
int result = 0;
if (overwrite || !getenv(name)) {
size_t length = strlen(name) + strlen(value) + 2;
- char *string = qemu_malloc(length);
+ char *string = g_malloc(length);
snprintf(string, length, "%s=%s", name, value);
result = putenv(string);
}
@@ -62,7 +62,7 @@ static PollingEntry *first_polling_entry;
int qemu_add_polling_cb(PollingFunc *func, void *opaque)
{
PollingEntry **ppe, *pe;
- pe = qemu_mallocz(sizeof(PollingEntry));
+ pe = g_malloc0(sizeof(PollingEntry));
pe->func = func;
pe->opaque = opaque;
for(ppe = &first_polling_entry; *ppe != NULL; ppe = &(*ppe)->next);
@@ -77,7 +77,7 @@ void qemu_del_polling_cb(PollingFunc *func, void *opaque)
pe = *ppe;
if (pe->func == func && pe->opaque == opaque) {
*ppe = pe->next;
- qemu_free(pe);
+ g_free(pe);
break;
}
}
@@ -218,7 +218,7 @@ char *os_find_datadir(const char *argv0)
p--;
*p = 0;
if (access(buf, R_OK) == 0) {
- return qemu_strdup(buf);
+ return g_strdup(buf);
}
return NULL;
}
diff --git a/pflib.c b/pflib.c
index 1154d0c9a..64cb2b3dd 100644
--- a/pflib.c
+++ b/pflib.c
@@ -145,7 +145,7 @@ static void convert_generic(QemuPfConv *conv, void *dst, void *src, uint32_t cnt
{
if (conv->conv_cnt < cnt) {
conv->conv_cnt = cnt;
- conv->conv_buf = qemu_realloc(conv->conv_buf, sizeof(QemuPixel) * conv->conv_cnt);
+ conv->conv_buf = g_realloc(conv->conv_buf, sizeof(QemuPixel) * conv->conv_cnt);
}
conv->conv_from(&conv->src, conv->conv_buf, src, cnt);
conv->conv_to(&conv->dst, dst, conv->conv_buf, cnt);
@@ -156,7 +156,7 @@ static void convert_generic(QemuPfConv *conv, void *dst, void *src, uint32_t cnt
QemuPfConv *qemu_pf_conv_get(PixelFormat *dst, PixelFormat *src)
{
- QemuPfConv *conv = qemu_mallocz(sizeof(QemuPfConv));
+ QemuPfConv *conv = g_malloc0(sizeof(QemuPfConv));
conv->src = *src;
conv->dst = *dst;
@@ -195,7 +195,7 @@ QemuPfConv *qemu_pf_conv_get(PixelFormat *dst, PixelFormat *src)
return conv;
err:
- qemu_free(conv);
+ g_free(conv);
return NULL;
}
@@ -207,7 +207,7 @@ void qemu_pf_conv_run(QemuPfConv *conv, void *dst, void *src, uint32_t cnt)
void qemu_pf_conv_put(QemuPfConv *conv)
{
if (conv) {
- qemu_free(conv->conv_buf);
- qemu_free(conv);
+ g_free(conv->conv_buf);
+ g_free(conv);
}
}
diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index 8dc00cbb0..babb0940d 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -634,7 +634,7 @@ int paio_init(void)
if (posix_aio_state)
return 0;
- s = qemu_malloc(sizeof(PosixAioState));
+ s = g_malloc(sizeof(PosixAioState));
sigfillset(&act.sa_mask);
act.sa_flags = 0; /* do not restart syscalls to interrupt select() */
diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
index 8cde4dd0d..f6290611f 100644
--- a/qapi/qapi-dealloc-visitor.c
+++ b/qapi/qapi-dealloc-visitor.c
@@ -35,7 +35,7 @@ static QapiDeallocVisitor *to_qov(Visitor *v)
static void qapi_dealloc_push(QapiDeallocVisitor *qov, void *value)
{
- StackEntry *e = qemu_mallocz(sizeof(*e));
+ StackEntry *e = g_malloc0(sizeof(*e));
e->value = value;
QTAILQ_INSERT_HEAD(&qov->stack, e, node);
@@ -47,7 +47,7 @@ static void *qapi_dealloc_pop(QapiDeallocVisitor *qov)
QObject *value;
QTAILQ_REMOVE(&qov->stack, e, node);
value = e->value;
- qemu_free(e);
+ g_free(e);
return value;
}
@@ -64,7 +64,7 @@ static void qapi_dealloc_end_struct(Visitor *v, Error **errp)
QapiDeallocVisitor *qov = to_qov(v);
void **obj = qapi_dealloc_pop(qov);
if (obj) {
- qemu_free(*obj);
+ g_free(*obj);
}
}
@@ -76,7 +76,7 @@ static GenericList *qapi_dealloc_next_list(Visitor *v, GenericList **list,
Error **errp)
{
GenericList *retval = *list;
- qemu_free(retval->value);
+ g_free(retval->value);
*list = retval->next;
return retval;
}
@@ -89,7 +89,7 @@ static void qapi_dealloc_type_str(Visitor *v, char **obj, const char *name,
Error **errp)
{
if (obj) {
- qemu_free(*obj);
+ g_free(*obj);
}
}
@@ -121,14 +121,14 @@ Visitor *qapi_dealloc_get_visitor(QapiDeallocVisitor *v)
void qapi_dealloc_visitor_cleanup(QapiDeallocVisitor *v)
{
- qemu_free(v);
+ g_free(v);
}
QapiDeallocVisitor *qapi_dealloc_visitor_new(void)
{
QapiDeallocVisitor *v;
- v = qemu_mallocz(sizeof(*v));
+ v = g_malloc0(sizeof(*v));
v->visitor.start_struct = qapi_dealloc_start_struct;
v->visitor.end_struct = qapi_dealloc_end_struct;
diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c
index 6a1adc9fc..fcf8bf920 100644
--- a/qapi/qmp-input-visitor.c
+++ b/qapi/qmp-input-visitor.c
@@ -99,7 +99,7 @@ static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind,
}
if (obj) {
- *obj = qemu_mallocz(size);
+ *obj = g_malloc0(size);
}
}
@@ -135,11 +135,11 @@ static GenericList *qmp_input_next_list(Visitor *v, GenericList **list,
return NULL;
}
- entry = qemu_mallocz(sizeof(*entry));
+ entry = g_malloc0(sizeof(*entry));
if (*list) {
so->entry = qlist_next(so->entry);
if (so->entry == NULL) {
- qemu_free(entry);
+ g_free(entry);
return NULL;
}
(*list)->next = entry;
@@ -199,7 +199,7 @@ static void qmp_input_type_str(Visitor *v, char **obj, const char *name,
return;
}
- *obj = qemu_strdup(qstring_get_str(qobject_to_qstring(qobj)));
+ *obj = g_strdup(qstring_get_str(qobject_to_qstring(qobj)));
}
static void qmp_input_type_number(Visitor *v, double *obj, const char *name,
@@ -272,14 +272,14 @@ Visitor *qmp_input_get_visitor(QmpInputVisitor *v)
void qmp_input_visitor_cleanup(QmpInputVisitor *v)
{
qobject_decref(v->obj);
- qemu_free(v);
+ g_free(v);
}
QmpInputVisitor *qmp_input_visitor_new(QObject *obj)
{
QmpInputVisitor *v;
- v = qemu_mallocz(sizeof(*v));
+ v = g_malloc0(sizeof(*v));
v->visitor.start_struct = qmp_input_start_struct;
v->visitor.end_struct = qmp_input_end_struct;
diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c
index c398cac4f..4419a3164 100644
--- a/qapi/qmp-output-visitor.c
+++ b/qapi/qmp-output-visitor.c
@@ -42,7 +42,7 @@ static QmpOutputVisitor *to_qov(Visitor *v)
static void qmp_output_push_obj(QmpOutputVisitor *qov, QObject *value)
{
- QStackEntry *e = qemu_mallocz(sizeof(*e));
+ QStackEntry *e = g_malloc0(sizeof(*e));
e->value = value;
QTAILQ_INSERT_HEAD(&qov->stack, e, node);
@@ -54,7 +54,7 @@ static QObject *qmp_output_pop(QmpOutputVisitor *qov)
QObject *value;
QTAILQ_REMOVE(&qov->stack, e, node);
value = e->value;
- qemu_free(e);
+ g_free(e);
return value;
}
@@ -210,17 +210,17 @@ void qmp_output_visitor_cleanup(QmpOutputVisitor *v)
if (e->value) {
qobject_decref(e->value);
}
- qemu_free(e);
+ g_free(e);
}
- qemu_free(v);
+ g_free(v);
}
QmpOutputVisitor *qmp_output_visitor_new(void)
{
QmpOutputVisitor *v;
- v = qemu_mallocz(sizeof(*v));
+ v = g_malloc0(sizeof(*v));
v->visitor.start_struct = qmp_output_start_struct;
v->visitor.end_struct = qmp_output_end_struct;
diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c
index 3fe8866d4..5ff99cff1 100644
--- a/qapi/qmp-registry.c
+++ b/qapi/qmp-registry.c
@@ -19,7 +19,7 @@ static QTAILQ_HEAD(, QmpCommand) qmp_commands =
void qmp_register_command(const char *name, QmpCommandFunc *fn)
{
- QmpCommand *cmd = qemu_mallocz(sizeof(*cmd));
+ QmpCommand *cmd = g_malloc0(sizeof(*cmd));
cmd->name = name;
cmd->type = QCT_NORMAL;
diff --git a/qbool.c b/qbool.c
index ad4873f62..590cd716e 100644
--- a/qbool.c
+++ b/qbool.c
@@ -31,7 +31,7 @@ QBool *qbool_from_int(int value)
{
QBool *qb;
- qb = qemu_malloc(sizeof(*qb));
+ qb = g_malloc(sizeof(*qb));
qb->value = value;
QOBJECT_INIT(qb, &qbool_type);
@@ -64,5 +64,5 @@ QBool *qobject_to_qbool(const QObject *obj)
static void qbool_destroy_obj(QObject *obj)
{
assert(obj != NULL);
- qemu_free(qobject_to_qbool(obj));
+ g_free(qobject_to_qbool(obj));
}
diff --git a/qdict.c b/qdict.c
index dee0fb447..4bf308b61 100644
--- a/qdict.c
+++ b/qdict.c
@@ -35,7 +35,7 @@ QDict *qdict_new(void)
{
QDict *qdict;
- qdict = qemu_mallocz(sizeof(*qdict));
+ qdict = g_malloc0(sizeof(*qdict));
QOBJECT_INIT(qdict, &qdict_type);
return qdict;
@@ -75,8 +75,8 @@ static QDictEntry *alloc_entry(const char *key, QObject *value)
{
QDictEntry *entry;
- entry = qemu_mallocz(sizeof(*entry));
- entry->key = qemu_strdup(key);
+ entry = g_malloc0(sizeof(*entry));
+ entry->key = g_strdup(key);
entry->value = value;
return entry;
@@ -410,8 +410,8 @@ static void qentry_destroy(QDictEntry *e)
assert(e->value != NULL);
qobject_decref(e->value);
- qemu_free(e->key);
- qemu_free(e);
+ g_free(e->key);
+ g_free(e);
}
/**
@@ -452,5 +452,5 @@ static void qdict_destroy_obj(QObject *obj)
}
}
- qemu_free(qdict);
+ g_free(qdict);
}
diff --git a/qemu-char.c b/qemu-char.c
index 8e8cf31a2..2358117bb 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -228,7 +228,7 @@ static int qemu_chr_open_null(QemuOpts *opts, CharDriverState **_chr)
{
CharDriverState *chr;
- chr = qemu_mallocz(sizeof(CharDriverState));
+ chr = g_malloc0(sizeof(CharDriverState));
chr->chr_write = null_chr_write;
*_chr= chr;
@@ -477,8 +477,8 @@ static CharDriverState *qemu_chr_open_mux(CharDriverState *drv)
CharDriverState *chr;
MuxDriver *d;
- chr = qemu_mallocz(sizeof(CharDriverState));
- d = qemu_mallocz(sizeof(MuxDriver));
+ chr = g_malloc0(sizeof(CharDriverState));
+ d = g_malloc0(sizeof(MuxDriver));
chr->opaque = d;
d->drv = drv;
@@ -617,7 +617,7 @@ static void fd_chr_close(struct CharDriverState *chr)
}
}
- qemu_free(s);
+ g_free(s);
qemu_chr_event(chr, CHR_EVENT_CLOSED);
}
@@ -627,8 +627,8 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out)
CharDriverState *chr;
FDCharDriver *s;
- chr = qemu_mallocz(sizeof(CharDriverState));
- s = qemu_mallocz(sizeof(FDCharDriver));
+ chr = g_malloc0(sizeof(CharDriverState));
+ s = g_malloc0(sizeof(FDCharDriver));
s->fd_in = fd_in;
s->fd_out = fd_out;
chr->opaque = s;
@@ -981,7 +981,7 @@ static void pty_chr_close(struct CharDriverState *chr)
close(s->fd);
qemu_del_timer(s->timer);
qemu_free_timer(s->timer);
- qemu_free(s);
+ g_free(s);
qemu_chr_event(chr, CHR_EVENT_CLOSED);
}
@@ -999,8 +999,8 @@ static int qemu_chr_open_pty(QemuOpts *opts, CharDriverState **_chr)
#define q_ptsname(x) ptsname(x)
#endif
- chr = qemu_mallocz(sizeof(CharDriverState));
- s = qemu_mallocz(sizeof(PtyCharDriver));
+ chr = g_malloc0(sizeof(CharDriverState));
+ s = g_malloc0(sizeof(PtyCharDriver));
if (openpty(&s->fd, &slave_fd, pty_name, NULL, NULL) < 0) {
return -errno;
@@ -1013,7 +1013,7 @@ static int qemu_chr_open_pty(QemuOpts *opts, CharDriverState **_chr)
close(slave_fd);
len = strlen(q_ptsname(s->fd)) + 5;
- chr->filename = qemu_malloc(len);
+ chr->filename = g_malloc(len);
snprintf(chr->filename, len, "pty:%s", q_ptsname(s->fd));
qemu_opt_set(opts, "path", q_ptsname(s->fd));
fprintf(stderr, "char device redirected to %s\n", q_ptsname(s->fd));
@@ -1358,7 +1358,7 @@ static void pp_close(CharDriverState *chr)
pp_hw_mode(drv, IEEE1284_MODE_COMPAT);
ioctl(fd, PPRELEASE);
close(fd);
- qemu_free(drv);
+ g_free(drv);
qemu_chr_event(chr, CHR_EVENT_CLOSED);
}
@@ -1379,11 +1379,11 @@ static int qemu_chr_open_pp(QemuOpts *opts, CharDriverState **_chr)
return -errno;
}
- drv = qemu_mallocz(sizeof(ParallelCharDriver));
+ drv = g_malloc0(sizeof(ParallelCharDriver));
drv->fd = fd;
drv->mode = IEEE1284_MODE_COMPAT;
- chr = qemu_mallocz(sizeof(CharDriverState));
+ chr = g_malloc0(sizeof(CharDriverState));
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
chr->chr_close = pp_close;
@@ -1445,7 +1445,7 @@ static int qemu_chr_open_pp(QemuOpts *opts, CharDriverState **_chr)
return -errno;
}
- chr = qemu_mallocz(sizeof(CharDriverState));
+ chr = g_malloc0(sizeof(CharDriverState));
chr->opaque = (void *)(intptr_t)fd;
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
@@ -1663,8 +1663,8 @@ static int qemu_chr_open_win(QemuOpts *opts, CharDriverState **_chr)
CharDriverState *chr;
WinCharState *s;
- chr = qemu_mallocz(sizeof(CharDriverState));
- s = qemu_mallocz(sizeof(WinCharState));
+ chr = g_malloc0(sizeof(CharDriverState));
+ s = g_malloc0(sizeof(WinCharState));
chr->opaque = s;
chr->chr_write = win_chr_write;
chr->chr_close = win_chr_close;
@@ -1765,8 +1765,8 @@ static int qemu_chr_open_win_pipe(QemuOpts *opts, CharDriverState **_chr)
CharDriverState *chr;
WinCharState *s;
- chr = qemu_mallocz(sizeof(CharDriverState));
- s = qemu_mallocz(sizeof(WinCharState));
+ chr = g_malloc0(sizeof(CharDriverState));
+ s = g_malloc0(sizeof(WinCharState));
chr->opaque = s;
chr->chr_write = win_chr_write;
chr->chr_close = win_chr_close;
@@ -1787,8 +1787,8 @@ static int qemu_chr_open_win_file(HANDLE fd_out, CharDriverState **pchr)
CharDriverState *chr;
WinCharState *s;
- chr = qemu_mallocz(sizeof(CharDriverState));
- s = qemu_mallocz(sizeof(WinCharState));
+ chr = g_malloc0(sizeof(CharDriverState));
+ s = g_malloc0(sizeof(WinCharState));
s->hcom = fd_out;
chr->opaque = s;
chr->chr_write = win_chr_write;
@@ -1890,7 +1890,7 @@ static void udp_chr_close(CharDriverState *chr)
qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
closesocket(s->fd);
}
- qemu_free(s);
+ g_free(s);
qemu_chr_event(chr, CHR_EVENT_CLOSED);
}
@@ -1901,8 +1901,8 @@ static int qemu_chr_open_udp(QemuOpts *opts, CharDriverState **_chr)
int fd = -1;
int ret;
- chr = qemu_mallocz(sizeof(CharDriverState));
- s = qemu_mallocz(sizeof(NetCharDriver));
+ chr = g_malloc0(sizeof(CharDriverState));
+ s = g_malloc0(sizeof(NetCharDriver));
fd = inet_dgram_opts(opts);
if (fd < 0) {
@@ -1923,8 +1923,8 @@ static int qemu_chr_open_udp(QemuOpts *opts, CharDriverState **_chr)
return 0;
return_err:
- qemu_free(chr);
- qemu_free(s);
+ g_free(chr);
+ g_free(s);
if (fd >= 0) {
closesocket(fd);
}
@@ -2215,7 +2215,7 @@ static void tcp_chr_close(CharDriverState *chr)
qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL);
closesocket(s->listen_fd);
}
- qemu_free(s);
+ g_free(s);
qemu_chr_event(chr, CHR_EVENT_CLOSED);
}
@@ -2239,8 +2239,8 @@ static int qemu_chr_open_socket(QemuOpts *opts, CharDriverState **_chr)
if (!is_listen)
is_waitconnect = 0;
- chr = qemu_mallocz(sizeof(CharDriverState));
- s = qemu_mallocz(sizeof(TCPCharDriver));
+ chr = g_malloc0(sizeof(CharDriverState));
+ s = g_malloc0(sizeof(TCPCharDriver));
if (is_unix) {
if (is_listen) {
@@ -2290,7 +2290,7 @@ static int qemu_chr_open_socket(QemuOpts *opts, CharDriverState **_chr)
}
/* for "info chardev" monitor command */
- chr->filename = qemu_malloc(256);
+ chr->filename = g_malloc(256);
if (is_unix) {
snprintf(chr->filename, 256, "unix:%s%s",
qemu_opt_get(opts, "path"),
@@ -2318,8 +2318,8 @@ static int qemu_chr_open_socket(QemuOpts *opts, CharDriverState **_chr)
fail:
if (fd >= 0)
closesocket(fd);
- qemu_free(s);
- qemu_free(chr);
+ g_free(s);
+ g_free(chr);
return ret;
}
@@ -2341,7 +2341,7 @@ static int mem_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
/* grow outbuf */
d->outbuf_capacity += len;
d->outbuf_capacity *= 2;
- d->outbuf = qemu_realloc(d->outbuf, d->outbuf_capacity);
+ d->outbuf = g_realloc(d->outbuf, d->outbuf_capacity);
}
memcpy(d->outbuf + d->outbuf_size, buf, len);
@@ -2354,10 +2354,10 @@ void qemu_chr_init_mem(CharDriverState *chr)
{
MemoryDriver *d;
- d = qemu_malloc(sizeof(*d));
+ d = g_malloc(sizeof(*d));
d->outbuf_size = 0;
d->outbuf_capacity = 4096;
- d->outbuf = qemu_mallocz(d->outbuf_capacity);
+ d->outbuf = g_malloc0(d->outbuf_capacity);
memset(chr, 0, sizeof(*chr));
chr->opaque = d;
@@ -2375,8 +2375,8 @@ void qemu_chr_close_mem(CharDriverState *chr)
{
MemoryDriver *d = chr->opaque;
- qemu_free(d->outbuf);
- qemu_free(chr->opaque);
+ g_free(d->outbuf);
+ g_free(chr->opaque);
chr->opaque = NULL;
chr->chr_write = NULL;
}
@@ -2583,14 +2583,14 @@ CharDriverState *qemu_chr_open_opts(QemuOpts *opts,
}
if (!chr->filename)
- chr->filename = qemu_strdup(qemu_opt_get(opts, "backend"));
+ chr->filename = g_strdup(qemu_opt_get(opts, "backend"));
chr->init = init;
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
if (qemu_opt_get_bool(opts, "mux", 0)) {
CharDriverState *base = chr;
int len = strlen(qemu_opts_id(opts)) + 6;
- base->label = qemu_malloc(len);
+ base->label = g_malloc(len);
snprintf(base->label, len, "%s-base", qemu_opts_id(opts));
chr = qemu_chr_open_mux(base);
chr->filename = base->filename;
@@ -2599,7 +2599,7 @@ CharDriverState *qemu_chr_open_opts(QemuOpts *opts,
} else {
chr->avail_connections = 1;
}
- chr->label = qemu_strdup(qemu_opts_id(opts));
+ chr->label = g_strdup(qemu_opts_id(opts));
return chr;
}
@@ -2651,9 +2651,9 @@ void qemu_chr_close(CharDriverState *chr)
QTAILQ_REMOVE(&chardevs, chr, next);
if (chr->chr_close)
chr->chr_close(chr);
- qemu_free(chr->filename);
- qemu_free(chr->label);
- qemu_free(chr);
+ g_free(chr->filename);
+ g_free(chr->label);
+ g_free(chr);
}
static void qemu_chr_qlist_iter(QObject *obj, void *opaque)
diff --git a/qemu-ga.c b/qemu-ga.c
index 869ee3709..eb632b7b5 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -610,7 +610,7 @@ int main(int argc, char **argv)
become_daemon(pidfile);
}
- s = qemu_mallocz(sizeof(GAState));
+ s = g_malloc0(sizeof(GAState));
s->conn_channel = NULL;
s->path = path;
s->method = method;
diff --git a/qemu-img.c b/qemu-img.c
index b205e98dd..95f321957 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -713,7 +713,7 @@ static int img_convert(int argc, char **argv)
qemu_progress_init(progress, 2.0);
qemu_progress_print(0, 100);
- bs = qemu_mallocz(bs_n * sizeof(BlockDriverState *));
+ bs = g_malloc0(bs_n * sizeof(BlockDriverState *));
total_sectors = 0;
for (bs_i = 0; bs_i < bs_n; bs_i++) {
@@ -834,7 +834,7 @@ static int img_convert(int argc, char **argv)
bs_i = 0;
bs_offset = 0;
bdrv_get_geometry(bs[0], &bs_sectors);
- buf = qemu_malloc(IO_BUF_SIZE);
+ buf = g_malloc(IO_BUF_SIZE);
if (compress) {
ret = bdrv_get_info(out_bs, &bdi);
@@ -1006,7 +1006,7 @@ out:
qemu_progress_end();
free_option_parameters(create_options);
free_option_parameters(param);
- qemu_free(buf);
+ g_free(buf);
if (out_bs) {
bdrv_delete(out_bs);
}
@@ -1016,7 +1016,7 @@ out:
bdrv_delete(bs[bs_i]);
}
}
- qemu_free(bs);
+ g_free(bs);
}
if (ret) {
return 1;
@@ -1040,7 +1040,7 @@ static void dump_snapshots(BlockDriverState *bs)
sn = &sn_tab[i];
printf("%s\n", bdrv_snapshot_dump(buf, sizeof(buf), sn));
}
- qemu_free(sn_tab);
+ g_free(sn_tab);
}
static int img_info(int argc, char **argv)
@@ -1373,8 +1373,8 @@ static int img_rebase(int argc, char **argv)
uint8_t * buf_new;
float local_progress;
- buf_old = qemu_malloc(IO_BUF_SIZE);
- buf_new = qemu_malloc(IO_BUF_SIZE);
+ buf_old = g_malloc(IO_BUF_SIZE);
+ buf_new = g_malloc(IO_BUF_SIZE);
bdrv_get_geometry(bs, &num_sectors);
@@ -1430,8 +1430,8 @@ static int img_rebase(int argc, char **argv)
qemu_progress_print(local_progress, 100);
}
- qemu_free(buf_old);
- qemu_free(buf_new);
+ g_free(buf_old);
+ g_free(buf_new);
}
/*
diff --git a/qemu-io.c b/qemu-io.c
index a553d0c98..7e40c4895 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -950,9 +950,9 @@ static int multiwrite_f(int argc, char **argv)
}
}
- reqs = qemu_malloc(nr_reqs * sizeof(*reqs));
- buf = qemu_malloc(nr_reqs * sizeof(*buf));
- qiovs = qemu_malloc(nr_reqs * sizeof(*qiovs));
+ reqs = g_malloc(nr_reqs * sizeof(*reqs));
+ buf = g_malloc(nr_reqs * sizeof(*buf));
+ qiovs = g_malloc(nr_reqs * sizeof(*qiovs));
for (i = 0; i < nr_reqs; i++) {
int j;
@@ -1017,9 +1017,9 @@ out:
qemu_io_free(buf[i]);
qemu_iovec_destroy(&qiovs[i]);
}
- qemu_free(buf);
- qemu_free(reqs);
- qemu_free(qiovs);
+ g_free(buf);
+ g_free(reqs);
+ g_free(qiovs);
return 0;
}
diff --git a/qemu-nbd.c b/qemu-nbd.c
index d91c02ce4..0b25a4dd4 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -431,7 +431,7 @@ int main(int argc, char **argv)
/* children */
}
- sharing_fds = qemu_malloc((shared + 1) * sizeof(int));
+ sharing_fds = g_malloc((shared + 1) * sizeof(int));
if (socket) {
sharing_fds[0] = unix_socket_incoming(socket);
@@ -491,7 +491,7 @@ int main(int argc, char **argv)
close(sharing_fds[0]);
bdrv_close(bs);
- qemu_free(sharing_fds);
+ g_free(sharing_fds);
if (socket)
unlink(socket);
diff --git a/qemu-option.c b/qemu-option.c
index 65db54292..105d760a8 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -277,7 +277,7 @@ int set_option_parameter(QEMUOptionParameter *list, const char *name,
case OPT_STRING:
if (value != NULL) {
- list->value.s = qemu_strdup(value);
+ list->value.s = g_strdup(value);
} else {
fprintf(stderr, "Option '%s' needs a parameter\n", name);
return -1;
@@ -337,12 +337,12 @@ void free_option_parameters(QEMUOptionParameter *list)
while (cur && cur->name) {
if (cur->type == OPT_STRING) {
- qemu_free(cur->value.s);
+ g_free(cur->value.s);
}
cur++;
}
- qemu_free(list);
+ g_free(list);
}
/*
@@ -377,7 +377,7 @@ QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest,
num_options += count_option_parameters(list);
- dest = qemu_realloc(dest, (num_options + 1) * sizeof(QEMUOptionParameter));
+ dest = g_realloc(dest, (num_options + 1) * sizeof(QEMUOptionParameter));
dest[num_dest_options].name = NULL;
while (list && list->name) {
@@ -594,9 +594,9 @@ static int qemu_opt_parse(QemuOpt *opt)
static void qemu_opt_del(QemuOpt *opt)
{
QTAILQ_REMOVE(&opt->opts->head, opt, next);
- qemu_free((/* !const */ char*)opt->name);
- qemu_free((/* !const */ char*)opt->str);
- qemu_free(opt);
+ g_free((/* !const */ char*)opt->name);
+ g_free((/* !const */ char*)opt->str);
+ g_free(opt);
}
int qemu_opt_set(QemuOpts *opts, const char *name, const char *value)
@@ -619,15 +619,15 @@ int qemu_opt_set(QemuOpts *opts, const char *name, const char *value)
}
}
- opt = qemu_mallocz(sizeof(*opt));
- opt->name = qemu_strdup(name);
+ opt = g_malloc0(sizeof(*opt));
+ opt->name = g_strdup(name);
opt->opts = opts;
QTAILQ_INSERT_TAIL(&opts->head, opt, next);
if (desc[i].name != NULL) {
opt->desc = desc+i;
}
if (value) {
- opt->str = qemu_strdup(value);
+ opt->str = g_strdup(value);
}
if (qemu_opt_parse(opt) < 0) {
qemu_opt_del(opt);
@@ -701,9 +701,9 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exist
}
}
}
- opts = qemu_mallocz(sizeof(*opts));
+ opts = g_malloc0(sizeof(*opts));
if (id) {
- opts->id = qemu_strdup(id);
+ opts->id = g_strdup(id);
}
opts->list = list;
loc_save(&opts->loc);
@@ -754,8 +754,8 @@ void qemu_opts_del(QemuOpts *opts)
qemu_opt_del(opt);
}
QTAILQ_REMOVE(&opts->list->head, opts, next);
- qemu_free(opts->id);
- qemu_free(opts);
+ g_free(opts->id);
+ g_free(opts);
}
int qemu_opts_print(QemuOpts *opts, void *dummy)
diff --git a/qemu-sockets.c b/qemu-sockets.c
index eda1850e9..183a9cbbd 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -593,10 +593,10 @@ int unix_listen(const char *str, char *ostr, int olen)
if (optstr) {
len = optstr - str;
if (len) {
- path = qemu_malloc(len+1);
+ path = g_malloc(len+1);
snprintf(path, len+1, "%.*s", len, str);
qemu_opt_set(opts, "path", path);
- qemu_free(path);
+ g_free(path);
}
} else {
qemu_opt_set(opts, "path", str);
diff --git a/qemu-thread-win32.c b/qemu-thread-win32.c
index 2d2d5abe3..a27332e66 100644
--- a/qemu-thread-win32.c
+++ b/qemu-thread-win32.c
@@ -249,7 +249,7 @@ void qemu_thread_create(QemuThread *thread,
struct QemuThreadData *data;
qemu_thread_init();
- data = qemu_malloc(sizeof *data);
+ data = g_malloc(sizeof *data);
data->thread = thread;
data->start_routine = start_routine;
data->arg = arg;
diff --git a/qemu-timer.c b/qemu-timer.c
index 30e8f1272..19313d3b0 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -327,7 +327,7 @@ void configure_alarms(char const *opt)
exit(0);
}
- arg = qemu_strdup(opt);
+ arg = g_strdup(opt);
/* Reorder the array */
name = strtok(arg, ",");
@@ -356,7 +356,7 @@ next:
name = strtok(NULL, ",");
}
- qemu_free(arg);
+ g_free(arg);
if (cur) {
/* Disable remaining timers */
@@ -380,7 +380,7 @@ static QEMUClock *qemu_new_clock(int type)
{
QEMUClock *clock;
- clock = qemu_mallocz(sizeof(QEMUClock));
+ clock = g_malloc0(sizeof(QEMUClock));
clock->type = type;
clock->enabled = 1;
notifier_list_init(&clock->reset_notifiers);
@@ -485,7 +485,7 @@ QEMUTimer *qemu_new_timer(QEMUClock *clock, int scale,
{
QEMUTimer *ts;
- ts = qemu_mallocz(sizeof(QEMUTimer));
+ ts = g_malloc0(sizeof(QEMUTimer));
ts->clock = clock;
ts->cb = cb;
ts->opaque = opaque;
@@ -495,7 +495,7 @@ QEMUTimer *qemu_new_timer(QEMUClock *clock, int scale,
void qemu_free_timer(QEMUTimer *ts)
{
- qemu_free(ts);
+ g_free(ts);
}
/* stop a timer, but do not dealloc it */
diff --git a/qemu-tool.c b/qemu-tool.c
index 41e5c4156..eb89fe0c1 100644
--- a/qemu-tool.c
+++ b/qemu-tool.c
@@ -76,12 +76,12 @@ void qemu_notify_event(void)
QEMUTimer *qemu_new_timer(QEMUClock *clock, int scale,
QEMUTimerCB *cb, void *opaque)
{
- return qemu_malloc(1);
+ return g_malloc(1);
}
void qemu_free_timer(QEMUTimer *ts)
{
- qemu_free(ts);
+ g_free(ts);
}
void qemu_del_timer(QEMUTimer *ts)
diff --git a/qerror.c b/qerror.c
index 69c1bc9af..3d64b80b2 100644
--- a/qerror.c
+++ b/qerror.c
@@ -242,7 +242,7 @@ QError *qerror_new(void)
{
QError *qerr;
- qerr = qemu_mallocz(sizeof(*qerr));
+ qerr = g_malloc0(sizeof(*qerr));
QOBJECT_INIT(qerr, &qerror_type);
return qerr;
@@ -501,5 +501,5 @@ static void qerror_destroy_obj(QObject *obj)
qerr = qobject_to_qerror(obj);
QDECREF(qerr->error);
- qemu_free(qerr);
+ g_free(qerr);
}
diff --git a/qfloat.c b/qfloat.c
index f8c8a2eb2..98338f3b7 100644
--- a/qfloat.c
+++ b/qfloat.c
@@ -31,7 +31,7 @@ QFloat *qfloat_from_double(double value)
{
QFloat *qf;
- qf = qemu_malloc(sizeof(*qf));
+ qf = g_malloc(sizeof(*qf));
qf->value = value;
QOBJECT_INIT(qf, &qfloat_type);
@@ -64,5 +64,5 @@ QFloat *qobject_to_qfloat(const QObject *obj)
static void qfloat_destroy_obj(QObject *obj)
{
assert(obj != NULL);
- qemu_free(qobject_to_qfloat(obj));
+ g_free(qobject_to_qfloat(obj));
}
diff --git a/qga/guest-agent-command-state.c b/qga/guest-agent-command-state.c
index bc6e0bd4a..969da2328 100644
--- a/qga/guest-agent-command-state.c
+++ b/qga/guest-agent-command-state.c
@@ -27,7 +27,7 @@ void ga_command_state_add(GACommandState *cs,
void (*init)(void),
void (*cleanup)(void))
{
- GACommandGroup *cg = qemu_mallocz(sizeof(GACommandGroup));
+ GACommandGroup *cg = g_malloc0(sizeof(GACommandGroup));
cg->init = init;
cg->cleanup = cleanup;
cs->groups = g_slist_append(cs->groups, cg);
@@ -67,7 +67,7 @@ void ga_command_state_cleanup_all(GACommandState *cs)
GACommandState *ga_command_state_new(void)
{
- GACommandState *cs = qemu_mallocz(sizeof(GACommandState));
+ GACommandState *cs = g_malloc0(sizeof(GACommandState));
cs->groups = NULL;
return cs;
}
diff --git a/qga/guest-agent-commands.c b/qga/guest-agent-commands.c
index 30c406848..6da990481 100644
--- a/qga/guest-agent-commands.c
+++ b/qga/guest-agent-commands.c
@@ -56,7 +56,7 @@ void qmp_guest_ping(Error **err)
struct GuestAgentInfo *qmp_guest_info(Error **err)
{
- GuestAgentInfo *info = qemu_mallocz(sizeof(GuestAgentInfo));
+ GuestAgentInfo *info = g_malloc0(sizeof(GuestAgentInfo));
info->version = g_strdup(QGA_VERSION);
@@ -114,7 +114,7 @@ static void guest_file_handle_add(FILE *fh)
{
GuestFileHandle *gfh;
- gfh = qemu_mallocz(sizeof(GuestFileHandle));
+ gfh = g_malloc0(sizeof(GuestFileHandle));
gfh->id = fileno(fh);
gfh->fh = fh;
QTAILQ_INSERT_TAIL(&guest_file_state.filehandles, gfh, next);
@@ -185,7 +185,7 @@ void qmp_guest_file_close(int64_t handle, Error **err)
}
QTAILQ_REMOVE(&guest_file_state.filehandles, gfh, next);
- qemu_free(gfh);
+ g_free(gfh);
}
struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
@@ -210,21 +210,21 @@ struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
}
fh = gfh->fh;
- buf = qemu_mallocz(count+1);
+ buf = g_malloc0(count+1);
read_count = fread(buf, 1, count, fh);
if (ferror(fh)) {
slog("guest-file-read failed, handle: %ld", handle);
error_set(err, QERR_QGA_COMMAND_FAILED, "fread() failed");
} else {
buf[read_count] = 0;
- read_data = qemu_mallocz(sizeof(GuestFileRead));
+ read_data = g_malloc0(sizeof(GuestFileRead));
read_data->count = read_count;
read_data->eof = feof(fh);
if (read_count) {
read_data->buf_b64 = g_base64_encode(buf, read_count);
}
}
- qemu_free(buf);
+ g_free(buf);
clearerr(fh);
return read_data;
@@ -251,7 +251,7 @@ GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64,
if (!has_count) {
count = buf_len;
} else if (count < 0 || count > buf_len) {
- qemu_free(buf);
+ g_free(buf);
error_set(err, QERR_INVALID_PARAMETER, "count");
return NULL;
}
@@ -261,11 +261,11 @@ GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64,
slog("guest-file-write failed, handle: %ld", handle);
error_set(err, QERR_QGA_COMMAND_FAILED, "fwrite() error");
} else {
- write_data = qemu_mallocz(sizeof(GuestFileWrite));
+ write_data = g_malloc0(sizeof(GuestFileWrite));
write_data->count = write_count;
write_data->eof = feof(fh);
}
- qemu_free(buf);
+ g_free(buf);
clearerr(fh);
return write_data;
@@ -289,7 +289,7 @@ struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
if (ret == -1) {
error_set(err, QERR_QGA_COMMAND_FAILED, strerror(errno));
} else {
- seek_data = qemu_mallocz(sizeof(GuestFileRead));
+ seek_data = g_malloc0(sizeof(GuestFileRead));
seek_data->position = ftell(fh);
seek_data->eof = feof(fh);
}
@@ -355,9 +355,9 @@ static int guest_fsfreeze_build_mount_list(void)
QTAILQ_FOREACH_SAFE(mount, &guest_fsfreeze_state.mount_list, next, temp) {
QTAILQ_REMOVE(&guest_fsfreeze_state.mount_list, mount, next);
- qemu_free(mount->dirname);
- qemu_free(mount->devtype);
- qemu_free(mount);
+ g_free(mount->dirname);
+ g_free(mount->devtype);
+ g_free(mount);
}
fp = setmntent(mtab, "r");
@@ -379,9 +379,9 @@ static int guest_fsfreeze_build_mount_list(void)
continue;
}
- mount = qemu_mallocz(sizeof(GuestFsfreezeMount));
- mount->dirname = qemu_strdup(ment->mnt_dir);
- mount->devtype = qemu_strdup(ment->mnt_type);
+ mount = g_malloc0(sizeof(GuestFsfreezeMount));
+ mount->dirname = g_strdup(ment->mnt_dir);
+ mount->devtype = g_strdup(ment->mnt_type);
QTAILQ_INSERT_TAIL(&guest_fsfreeze_state.mount_list, mount, next);
}
diff --git a/qint.c b/qint.c
index fb3823a7f..ee51804fb 100644
--- a/qint.c
+++ b/qint.c
@@ -30,7 +30,7 @@ QInt *qint_from_int(int64_t value)
{
QInt *qi;
- qi = qemu_malloc(sizeof(*qi));
+ qi = g_malloc(sizeof(*qi));
qi->value = value;
QOBJECT_INIT(qi, &qint_type);
@@ -63,5 +63,5 @@ QInt *qobject_to_qint(const QObject *obj)
static void qint_destroy_obj(QObject *obj)
{
assert(obj != NULL);
- qemu_free(qobject_to_qint(obj));
+ g_free(qobject_to_qint(obj));
}
diff --git a/qlist.c b/qlist.c
index 5730fb87f..88498b157 100644
--- a/qlist.c
+++ b/qlist.c
@@ -31,7 +31,7 @@ QList *qlist_new(void)
{
QList *qlist;
- qlist = qemu_malloc(sizeof(*qlist));
+ qlist = g_malloc(sizeof(*qlist));
QTAILQ_INIT(&qlist->head);
QOBJECT_INIT(qlist, &qlist_type);
@@ -64,7 +64,7 @@ void qlist_append_obj(QList *qlist, QObject *value)
{
QListEntry *entry;
- entry = qemu_malloc(sizeof(*entry));
+ entry = g_malloc(sizeof(*entry));
entry->value = value;
QTAILQ_INSERT_TAIL(&qlist->head, entry, next);
@@ -98,7 +98,7 @@ QObject *qlist_pop(QList *qlist)
QTAILQ_REMOVE(&qlist->head, entry, next);
ret = entry->value;
- qemu_free(entry);
+ g_free(entry);
return ret;
}
@@ -150,8 +150,8 @@ static void qlist_destroy_obj(QObject *obj)
QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) {
QTAILQ_REMOVE(&qlist->head, entry, next);
qobject_decref(entry->value);
- qemu_free(entry);
+ g_free(entry);
}
- qemu_free(qlist);
+ g_free(qlist);
}
diff --git a/qstring.c b/qstring.c
index 4e2ba083b..b7e12e401 100644
--- a/qstring.c
+++ b/qstring.c
@@ -40,12 +40,12 @@ QString *qstring_from_substr(const char *str, int start, int end)
{
QString *qstring;
- qstring = qemu_malloc(sizeof(*qstring));
+ qstring = g_malloc(sizeof(*qstring));
qstring->length = end - start + 1;
qstring->capacity = qstring->length;
- qstring->string = qemu_malloc(qstring->capacity + 1);
+ qstring->string = g_malloc(qstring->capacity + 1);
memcpy(qstring->string, str + start, qstring->length);
qstring->string[qstring->length] = 0;
@@ -70,7 +70,7 @@ static void capacity_increase(QString *qstring, size_t len)
qstring->capacity += len;
qstring->capacity *= 2; /* use exponential growth */
- qstring->string = qemu_realloc(qstring->string, qstring->capacity + 1);
+ qstring->string = g_realloc(qstring->string, qstring->capacity + 1);
}
}
@@ -136,6 +136,6 @@ static void qstring_destroy_obj(QObject *obj)
assert(obj != NULL);
qs = qobject_to_qstring(obj);
- qemu_free(qs->string);
- qemu_free(qs);
+ g_free(qs->string);
+ g_free(qs);
}
diff --git a/readline.c b/readline.c
index 92f9cd156..6a3160aba 100644
--- a/readline.c
+++ b/readline.c
@@ -264,7 +264,7 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
void readline_add_completion(ReadLineState *rs, const char *str)
{
if (rs->nb_completions < READLINE_MAX_COMPLETIONS) {
- rs->completions[rs->nb_completions++] = qemu_strdup(str);
+ rs->completions[rs->nb_completions++] = g_strdup(str);
}
}
@@ -281,11 +281,11 @@ static void readline_completion(ReadLineState *rs)
rs->nb_completions = 0;
- cmdline = qemu_malloc(rs->cmd_buf_index + 1);
+ cmdline = g_malloc(rs->cmd_buf_index + 1);
memcpy(cmdline, rs->cmd_buf, rs->cmd_buf_index);
cmdline[rs->cmd_buf_index] = '\0';
rs->completion_finder(cmdline);
- qemu_free(cmdline);
+ g_free(cmdline);
/* no completion found */
if (rs->nb_completions <= 0)
@@ -466,7 +466,7 @@ const char *readline_get_history(ReadLineState *rs, unsigned int index)
ReadLineState *readline_init(Monitor *mon,
ReadLineCompletionFunc *completion_finder)
{
- ReadLineState *rs = qemu_mallocz(sizeof(*rs));
+ ReadLineState *rs = g_malloc0(sizeof(*rs));
rs->hist_entry = -1;
rs->mon = mon;
diff --git a/savevm.c b/savevm.c
index 7801aa705..b06308b56 100644
--- a/savevm.c
+++ b/savevm.c
@@ -206,7 +206,7 @@ static int socket_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
static int socket_close(void *opaque)
{
QEMUFileSocket *s = opaque;
- qemu_free(s);
+ g_free(s);
return 0;
}
@@ -234,7 +234,7 @@ static int stdio_pclose(void *opaque)
QEMUFileStdio *s = opaque;
int ret;
ret = pclose(s->stdio_file);
- qemu_free(s);
+ g_free(s);
return ret;
}
@@ -242,7 +242,7 @@ static int stdio_fclose(void *opaque)
{
QEMUFileStdio *s = opaque;
fclose(s->stdio_file);
- qemu_free(s);
+ g_free(s);
return 0;
}
@@ -255,7 +255,7 @@ QEMUFile *qemu_popen(FILE *stdio_file, const char *mode)
return NULL;
}
- s = qemu_mallocz(sizeof(QEMUFileStdio));
+ s = g_malloc0(sizeof(QEMUFileStdio));
s->stdio_file = stdio_file;
@@ -303,7 +303,7 @@ QEMUFile *qemu_fdopen(int fd, const char *mode)
return NULL;
}
- s = qemu_mallocz(sizeof(QEMUFileStdio));
+ s = g_malloc0(sizeof(QEMUFileStdio));
s->stdio_file = fdopen(fd, mode);
if (!s->stdio_file)
goto fail;
@@ -318,13 +318,13 @@ QEMUFile *qemu_fdopen(int fd, const char *mode)
return s->file;
fail:
- qemu_free(s);
+ g_free(s);
return NULL;
}
QEMUFile *qemu_fopen_socket(int fd)
{
- QEMUFileSocket *s = qemu_mallocz(sizeof(QEMUFileSocket));
+ QEMUFileSocket *s = g_malloc0(sizeof(QEMUFileSocket));
s->fd = fd;
s->file = qemu_fopen_ops(s, NULL, socket_get_buffer, socket_close,
@@ -358,7 +358,7 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode)
return NULL;
}
- s = qemu_mallocz(sizeof(QEMUFileStdio));
+ s = g_malloc0(sizeof(QEMUFileStdio));
s->stdio_file = fopen(filename, mode);
if (!s->stdio_file)
@@ -373,7 +373,7 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode)
}
return s->file;
fail:
- qemu_free(s);
+ g_free(s);
return NULL;
}
@@ -411,7 +411,7 @@ QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
{
QEMUFile *f;
- f = qemu_mallocz(sizeof(QEMUFile));
+ f = g_malloc0(sizeof(QEMUFile));
f->opaque = opaque;
f->put_buffer = put_buffer;
@@ -477,7 +477,7 @@ int qemu_fclose(QEMUFile *f)
qemu_fflush(f);
if (f->close)
ret = f->close(f->opaque);
- qemu_free(f);
+ g_free(f);
return ret;
}
@@ -1114,7 +1114,7 @@ int register_savevm_live(DeviceState *dev,
{
SaveStateEntry *se;
- se = qemu_mallocz(sizeof(SaveStateEntry));
+ se = g_malloc0(sizeof(SaveStateEntry));
se->version_id = version_id;
se->section_id = global_section_id++;
se->set_params = set_params;
@@ -1130,9 +1130,9 @@ int register_savevm_live(DeviceState *dev,
if (id) {
pstrcpy(se->idstr, sizeof(se->idstr), id);
pstrcat(se->idstr, sizeof(se->idstr), "/");
- qemu_free(id);
+ g_free(id);
- se->compat = qemu_mallocz(sizeof(CompatEntry));
+ se->compat = g_malloc0(sizeof(CompatEntry));
pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), idstr);
se->compat->instance_id = instance_id == -1 ?
calculate_compat_instance_id(idstr) : instance_id;
@@ -1174,7 +1174,7 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
if (path) {
pstrcpy(id, sizeof(id), path);
pstrcat(id, sizeof(id), "/");
- qemu_free(path);
+ g_free(path);
}
}
pstrcat(id, sizeof(id), idstr);
@@ -1183,9 +1183,9 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
QTAILQ_REMOVE(&savevm_handlers, se, entry);
if (se->compat) {
- qemu_free(se->compat);
+ g_free(se->compat);
}
- qemu_free(se);
+ g_free(se);
}
}
}
@@ -1203,7 +1203,7 @@ void register_device_unmigratable(DeviceState *dev, const char *idstr,
if (path) {
pstrcpy(id, sizeof(id), path);
pstrcat(id, sizeof(id), "/");
- qemu_free(path);
+ g_free(path);
}
}
pstrcat(id, sizeof(id), idstr);
@@ -1225,7 +1225,7 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
/* If this triggers, alias support can be dropped for the vmsd. */
assert(alias_id == -1 || required_for_version >= vmsd->minimum_version_id);
- se = qemu_mallocz(sizeof(SaveStateEntry));
+ se = g_malloc0(sizeof(SaveStateEntry));
se->version_id = vmsd->version_id;
se->section_id = global_section_id++;
se->save_live_state = NULL;
@@ -1241,9 +1241,9 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
if (id) {
pstrcpy(se->idstr, sizeof(se->idstr), id);
pstrcat(se->idstr, sizeof(se->idstr), "/");
- qemu_free(id);
+ g_free(id);
- se->compat = qemu_mallocz(sizeof(CompatEntry));
+ se->compat = g_malloc0(sizeof(CompatEntry));
pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->name);
se->compat->instance_id = instance_id == -1 ?
calculate_compat_instance_id(vmsd->name) : instance_id;
@@ -1279,9 +1279,9 @@ void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
if (se->vmsd == vmsd && se->opaque == opaque) {
QTAILQ_REMOVE(&savevm_handlers, se, entry);
if (se->compat) {
- qemu_free(se->compat);
+ g_free(se->compat);
}
- qemu_free(se);
+ g_free(se);
}
}
}
@@ -1785,7 +1785,7 @@ int qemu_loadvm_state(QEMUFile *f)
}
/* Add entry */
- le = qemu_mallocz(sizeof(*le));
+ le = g_malloc0(sizeof(*le));
le->se = se;
le->section_id = section_id;
@@ -1835,7 +1835,7 @@ int qemu_loadvm_state(QEMUFile *f)
out:
QLIST_FOREACH_SAFE(le, &loadvm_handlers, entry, new_le) {
QLIST_REMOVE(le, entry);
- qemu_free(le);
+ g_free(le);
}
if (qemu_file_has_error(f))
@@ -1862,7 +1862,7 @@ static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
break;
}
}
- qemu_free(sn_tab);
+ g_free(sn_tab);
return ret;
}
@@ -2141,7 +2141,7 @@ void do_info_snapshots(Monitor *mon)
return;
}
- available_snapshots = qemu_mallocz(sizeof(int) * nb_sns);
+ available_snapshots = g_malloc0(sizeof(int) * nb_sns);
total = 0;
for (i = 0; i < nb_sns; i++) {
sn = &sn_tab[i];
@@ -2174,7 +2174,7 @@ void do_info_snapshots(Monitor *mon)
monitor_printf(mon, "There is no suitable snapshot available\n");
}
- qemu_free(sn_tab);
- qemu_free(available_snapshots);
+ g_free(sn_tab);
+ g_free(available_snapshots);
}
diff --git a/slirp/misc.c b/slirp/misc.c
index 600255036..6c80e6968 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -182,7 +182,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
close(s);
i = 0;
- bptr = qemu_strdup(ex); /* No need to free() this */
+ bptr = g_strdup(ex); /* No need to free() this */
if (do_pty == 1) {
/* Setup "slirp.telnetd -x" */
argv[i++] = "slirp.telnetd";
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 2c242ef4e..655b3f40c 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -202,7 +202,7 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork,
const char *bootfile, struct in_addr vdhcp_start,
struct in_addr vnameserver, void *opaque)
{
- Slirp *slirp = qemu_mallocz(sizeof(Slirp));
+ Slirp *slirp = g_malloc0(sizeof(Slirp));
slirp_init_once();
@@ -222,10 +222,10 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork,
vhostname);
}
if (tftp_path) {
- slirp->tftp_prefix = qemu_strdup(tftp_path);
+ slirp->tftp_prefix = g_strdup(tftp_path);
}
if (bootfile) {
- slirp->bootp_filename = qemu_strdup(bootfile);
+ slirp->bootp_filename = g_strdup(bootfile);
}
slirp->vdhcp_startaddr = vdhcp_start;
slirp->vnameserver_addr = vnameserver;
@@ -246,9 +246,9 @@ void slirp_cleanup(Slirp *slirp)
unregister_savevm(NULL, "slirp", slirp);
- qemu_free(slirp->tftp_prefix);
- qemu_free(slirp->bootp_filename);
- qemu_free(slirp);
+ g_free(slirp->tftp_prefix);
+ g_free(slirp->bootp_filename);
+ g_free(slirp);
}
#define CONN_CANFSEND(so) (((so)->so_state & (SS_FCANTSENDMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED)
diff --git a/slirp/tftp.c b/slirp/tftp.c
index 8055ccc17..b78765f3a 100644
--- a/slirp/tftp.c
+++ b/slirp/tftp.c
@@ -37,7 +37,7 @@ static inline void tftp_session_update(struct tftp_session *spt)
static void tftp_session_terminate(struct tftp_session *spt)
{
- qemu_free(spt->filename);
+ g_free(spt->filename);
spt->slirp = NULL;
}
@@ -54,7 +54,7 @@ static int tftp_session_allocate(Slirp *slirp, struct tftp_t *tp)
/* sessions time out after 5 inactive seconds */
if ((int)(curtime - spt->timestamp) > 5000) {
- qemu_free(spt->filename);
+ g_free(spt->filename);
goto found;
}
}
@@ -287,7 +287,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct tftp_t *tp, int pktlen)
/* prepend tftp_prefix */
prefix_len = strlen(slirp->tftp_prefix);
- spt->filename = qemu_malloc(prefix_len + TFTP_FILENAME_MAX + 2);
+ spt->filename = g_malloc(prefix_len + TFTP_FILENAME_MAX + 2);
memcpy(spt->filename, slirp->tftp_prefix, prefix_len);
spt->filename[prefix_len] = '/';
diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 95bf6b65d..684024bf5 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -112,7 +112,7 @@ static int spice_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
assert(s->datalen == 0);
if (s->bufsize < len) {
s->bufsize = len;
- s->buffer = qemu_realloc(s->buffer, s->bufsize);
+ s->buffer = g_realloc(s->buffer, s->bufsize);
}
memcpy(s->buffer, buf, len);
s->datapos = s->buffer;
@@ -127,7 +127,7 @@ static void spice_chr_close(struct CharDriverState *chr)
printf("%s\n", __func__);
vmc_unregister_interface(s);
- qemu_free(s);
+ g_free(s);
}
static void spice_chr_guest_open(struct CharDriverState *chr)
@@ -185,8 +185,8 @@ int qemu_chr_open_spice(QemuOpts *opts, CharDriverState **_chr)
return -EINVAL;
}
- chr = qemu_mallocz(sizeof(CharDriverState));
- s = qemu_mallocz(sizeof(SpiceCharDriver));
+ chr = g_malloc0(sizeof(CharDriverState));
+ s = g_malloc0(sizeof(SpiceCharDriver));
s->chr = chr;
s->debug = debug;
s->active = false;
diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index c61906a8b..1e224a215 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -3449,7 +3449,7 @@ CPUAlphaState * cpu_alpha_init (const char *cpu_model)
CPUAlphaState *env;
int implver, amask, i, max;
- env = qemu_mallocz(sizeof(CPUAlphaState));
+ env = g_malloc0(sizeof(CPUAlphaState));
cpu_exec_init(env);
alpha_translate_init();
tlb_flush(env, 1);
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 8cae97234..d3a3ba207 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -384,7 +384,7 @@ CPUARMState *cpu_arm_init(const char *cpu_model)
id = cpu_arm_find_by_name(cpu_model);
if (id == 0)
return NULL;
- env = qemu_mallocz(sizeof(CPUARMState));
+ env = g_malloc0(sizeof(CPUARMState));
cpu_exec_init(env);
if (!inited) {
inited = 1;
diff --git a/target-cris/translate.c b/target-cris/translate.c
index dd85859c0..70abf8a09 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -3516,7 +3516,7 @@ CPUCRISState *cpu_cris_init (const char *cpu_model)
static int tcg_initialized = 0;
int i;
- env = qemu_mallocz(sizeof(CPUCRISState));
+ env = g_malloc0(sizeof(CPUCRISState));
env->pregs[PR_VR] = vr_by_name(cpu_model);
cpu_exec_init(env);
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 89e962385..1e8bcff65 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -1009,7 +1009,7 @@ static int cpudef_setfield(const char *name, const char *str, void *opaque)
*/
static int cpudef_register(QemuOpts *opts, void *opaque)
{
- x86_def_t *def = qemu_mallocz(sizeof (x86_def_t));
+ x86_def_t *def = g_malloc0(sizeof (x86_def_t));
qemu_opt_foreach(opts, cpudef_setfield, def, 1);
def->next = x86_defs;
diff --git a/target-i386/helper.c b/target-i386/helper.c
index f8c8633d8..5df40d466 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -108,7 +108,7 @@ void cpu_reset(CPUX86State *env)
void cpu_x86_close(CPUX86State *env)
{
- qemu_free(env);
+ g_free(env);
}
static void cpu_x86_version(CPUState *env, int *family, int *model)
@@ -1239,7 +1239,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model)
CPUX86State *env;
static int inited;
- env = qemu_mallocz(sizeof(CPUX86State));
+ env = g_malloc0(sizeof(CPUX86State));
cpu_exec_init(env);
env->cpu_model_str = cpu_model;
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 31b88b749..bd850ed7c 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -68,7 +68,7 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
int r, size;
size = sizeof(*cpuid) + max * sizeof(*cpuid->entries);
- cpuid = (struct kvm_cpuid2 *)qemu_mallocz(size);
+ cpuid = (struct kvm_cpuid2 *)g_malloc0(size);
cpuid->nent = max;
r = kvm_ioctl(s, KVM_GET_SUPPORTED_CPUID, cpuid);
if (r == 0 && cpuid->nent >= max) {
@@ -76,7 +76,7 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
}
if (r < 0) {
if (r == -E2BIG) {
- qemu_free(cpuid);
+ g_free(cpuid);
return NULL;
} else {
fprintf(stderr, "KVM_GET_SUPPORTED_CPUID failed: %s\n",
@@ -162,7 +162,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
}
}
- qemu_free(cpuid);
+ g_free(cpuid);
/* fallback for older kernels */
if (!has_kvm_features && (function == KVM_CPUID_FEATURES)) {
@@ -187,7 +187,7 @@ static void kvm_unpoison_all(void *param)
QLIST_FOREACH_SAFE(page, &hwpoison_page_list, list, next_page) {
QLIST_REMOVE(page, list);
qemu_ram_remap(page->ram_addr, TARGET_PAGE_SIZE);
- qemu_free(page);
+ g_free(page);
}
}
@@ -200,7 +200,7 @@ static void kvm_hwpoison_page_add(ram_addr_t ram_addr)
return;
}
}
- page = qemu_malloc(sizeof(HWPoisonPage));
+ page = g_malloc(sizeof(HWPoisonPage));
page->ram_addr = ram_addr;
QLIST_INSERT_HEAD(&hwpoison_page_list, page, list);
}
@@ -549,7 +549,7 @@ static int kvm_get_supported_msrs(KVMState *s)
}
/* Old kernel modules had a bug and could write beyond the provided
memory. Allocate at least a safe amount of 1K. */
- kvm_msr_list = qemu_mallocz(MAX(1024, sizeof(msr_list) +
+ kvm_msr_list = g_malloc0(MAX(1024, sizeof(msr_list) +
msr_list.nmsrs *
sizeof(msr_list.indices[0])));
@@ -570,7 +570,7 @@ static int kvm_get_supported_msrs(KVMState *s)
}
}
- qemu_free(kvm_msr_list);
+ g_free(kvm_msr_list);
}
return ret;
@@ -788,7 +788,7 @@ static int kvm_put_xsave(CPUState *env)
memcpy(&xsave->region[XSAVE_YMMH_SPACE], env->ymmh_regs,
sizeof env->ymmh_regs);
r = kvm_vcpu_ioctl(env, KVM_SET_XSAVE, xsave);
- qemu_free(xsave);
+ g_free(xsave);
return r;
}
@@ -969,7 +969,7 @@ static int kvm_get_xsave(CPUState *env)
xsave = qemu_memalign(4096, sizeof(struct kvm_xsave));
ret = kvm_vcpu_ioctl(env, KVM_GET_XSAVE, xsave);
if (ret < 0) {
- qemu_free(xsave);
+ g_free(xsave);
return ret;
}
@@ -993,7 +993,7 @@ static int kvm_get_xsave(CPUState *env)
env->xstate_bv = *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV];
memcpy(env->ymmh_regs, &xsave->region[XSAVE_YMMH_SPACE],
sizeof env->ymmh_regs);
- qemu_free(xsave);
+ g_free(xsave);
return 0;
}
diff --git a/target-lm32/helper.c b/target-lm32/helper.c
index 48c402e31..014fd8de0 100644
--- a/target-lm32/helper.c
+++ b/target-lm32/helper.c
@@ -208,7 +208,7 @@ CPUState *cpu_lm32_init(const char *cpu_model)
return NULL;
}
- env = qemu_mallocz(sizeof(CPUState));
+ env = g_malloc0(sizeof(CPUState));
env->features = def->features;
env->num_bps = def->num_breakpoints;
diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index 7ca75fb06..674c8e6f0 100644
--- a/target-m68k/helper.c
+++ b/target-m68k/helper.c
@@ -172,7 +172,7 @@ CPUM68KState *cpu_m68k_init(const char *cpu_model)
CPUM68KState *env;
static int inited;
- env = qemu_mallocz(sizeof(CPUM68KState));
+ env = g_malloc0(sizeof(CPUM68KState));
cpu_exec_init(env);
if (!inited) {
inited = 1;
@@ -193,7 +193,7 @@ CPUM68KState *cpu_m68k_init(const char *cpu_model)
void cpu_m68k_close(CPUM68KState *env)
{
- qemu_free(env);
+ g_free(env);
}
void cpu_m68k_flush_flags(CPUM68KState *env, int cc_op)
diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 41beb0a8e..1a862d31e 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -1846,7 +1846,7 @@ CPUState *cpu_mb_init (const char *cpu_model)
static int tcg_initialized = 0;
int i;
- env = qemu_mallocz(sizeof(CPUState));
+ env = g_malloc0(sizeof(CPUState));
cpu_exec_init(env);
cpu_reset(env);
diff --git a/target-mips/translate.c b/target-mips/translate.c
index 2848c6a69..6c4e0d767 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -12618,7 +12618,7 @@ CPUMIPSState *cpu_mips_init (const char *cpu_model)
def = cpu_mips_find_by_name(cpu_model);
if (!def)
return NULL;
- env = qemu_mallocz(sizeof(CPUMIPSState));
+ env = g_malloc0(sizeof(CPUMIPSState));
env->cpu_model = def;
env->cpu_model_str = cpu_model;
diff --git a/target-mips/translate_init.c b/target-mips/translate_init.c
index d55c522bf..5bb421562 100644
--- a/target-mips/translate_init.c
+++ b/target-mips/translate_init.c
@@ -535,7 +535,7 @@ static void r4k_mmu_init (CPUMIPSState *env, const mips_def_t *def)
static void mmu_init (CPUMIPSState *env, const mips_def_t *def)
{
- env->tlb = qemu_mallocz(sizeof(CPUMIPSTLBContext));
+ env->tlb = g_malloc0(sizeof(CPUMIPSTLBContext));
switch (def->mmu_type) {
case MMU_TYPE_NONE:
@@ -568,7 +568,7 @@ static void fpu_init (CPUMIPSState *env, const mips_def_t *def)
static void mvp_init (CPUMIPSState *env, const mips_def_t *def)
{
- env->mvp = qemu_mallocz(sizeof(CPUMIPSMVPContext));
+ env->mvp = g_malloc0(sizeof(CPUMIPSMVPContext));
/* MVPConf1 implemented, TLB sharable, no gating storage support,
programmable cache partitioning implemented, number of allocatable
diff --git a/target-ppc/helper.c b/target-ppc/helper.c
index 789e6aa32..3abab1a22 100644
--- a/target-ppc/helper.c
+++ b/target-ppc/helper.c
@@ -3089,7 +3089,7 @@ CPUPPCState *cpu_ppc_init (const char *cpu_model)
if (!def)
return NULL;
- env = qemu_mallocz(sizeof(CPUPPCState));
+ env = g_malloc0(sizeof(CPUPPCState));
cpu_exec_init(env);
if (tcg_enabled()) {
ppc_translate_init();
@@ -3105,5 +3105,5 @@ CPUPPCState *cpu_ppc_init (const char *cpu_model)
void cpu_ppc_close (CPUPPCState *env)
{
/* Should also remove all opcode tables... */
- qemu_free(env);
+ g_free(env);
}
diff --git a/target-ppc/kvm_ppc.c b/target-ppc/kvm_ppc.c
index 536fcabd4..867dc1d17 100644
--- a/target-ppc/kvm_ppc.c
+++ b/target-ppc/kvm_ppc.c
@@ -32,7 +32,7 @@ int kvmppc_read_host_property(const char *node_path, const char *prop,
pathlen = snprintf(NULL, 0, "%s/%s/%s", PROC_DEVTREE_PATH, node_path, prop)
+ 1;
- path = qemu_malloc(pathlen);
+ path = g_malloc(pathlen);
snprintf(path, pathlen, "%s/%s/%s", PROC_DEVTREE_PATH, node_path, prop);
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index f542b8e4f..9ea193dcf 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -9327,13 +9327,13 @@ static void init_ppc_proc (CPUPPCState *env, const ppc_def_t *def)
nb_tlb *= 2;
switch (env->tlb_type) {
case TLB_6XX:
- env->tlb.tlb6 = qemu_mallocz(nb_tlb * sizeof(ppc6xx_tlb_t));
+ env->tlb.tlb6 = g_malloc0(nb_tlb * sizeof(ppc6xx_tlb_t));
break;
case TLB_EMB:
- env->tlb.tlbe = qemu_mallocz(nb_tlb * sizeof(ppcemb_tlb_t));
+ env->tlb.tlbe = g_malloc0(nb_tlb * sizeof(ppcemb_tlb_t));
break;
case TLB_MAS:
- env->tlb.tlbm = qemu_mallocz(nb_tlb * sizeof(ppcmas_tlb_t));
+ env->tlb.tlbm = g_malloc0(nb_tlb * sizeof(ppcmas_tlb_t));
break;
}
/* Pre-compute some useful values */
diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index db88603d7..96dd867d7 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -79,7 +79,7 @@ CPUS390XState *cpu_s390x_init(const char *cpu_model)
static int inited = 0;
static int cpu_num = 0;
- env = qemu_mallocz(sizeof(CPUS390XState));
+ env = g_malloc0(sizeof(CPUS390XState));
cpu_exec_init(env);
if (tcg_enabled() && !inited) {
inited = 1;
diff --git a/target-sh4/translate.c b/target-sh4/translate.c
index 569bc738c..bad357772 100644
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -279,7 +279,7 @@ CPUSH4State *cpu_sh4_init(const char *cpu_model)
def = cpu_sh4_find_by_name(cpu_model);
if (!def)
return NULL;
- env = qemu_mallocz(sizeof(CPUSH4State));
+ env = g_malloc0(sizeof(CPUSH4State));
env->features = def->features;
cpu_exec_init(env);
env->movcal_backup_tail = &(env->movcal_backup);
diff --git a/target-sparc/helper.c b/target-sparc/helper.c
index 47110a55c..1fe1f074e 100644
--- a/target-sparc/helper.c
+++ b/target-sparc/helper.c
@@ -1091,7 +1091,7 @@ static int cpu_sparc_register(CPUSPARCState *env, const char *cpu_model)
if (cpu_sparc_find_by_name(def, cpu_model) < 0)
return -1;
- env->def = qemu_mallocz(sizeof(*def));
+ env->def = g_malloc0(sizeof(*def));
memcpy(env->def, def, sizeof(*def));
#if defined(CONFIG_USER_ONLY)
if ((env->def->features & CPU_FEATURE_FLOAT))
@@ -1124,7 +1124,7 @@ CPUSPARCState *cpu_sparc_init(const char *cpu_model)
{
CPUSPARCState *env;
- env = qemu_mallocz(sizeof(CPUSPARCState));
+ env = g_malloc0(sizeof(CPUSPARCState));
cpu_exec_init(env);
gen_intermediate_code_init(env);
diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c
index 8edfcb75b..b5b1cb7c9 100644
--- a/target-unicore32/helper.c
+++ b/target-unicore32/helper.c
@@ -53,7 +53,7 @@ CPUState *uc32_cpu_init(const char *cpu_model)
uint32_t id;
static int inited = 1;
- env = qemu_mallocz(sizeof(CPUState));
+ env = g_malloc0(sizeof(CPUState));
cpu_exec_init(env);
id = uc32_cpu_find_by_name(cpu_model);
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 92f198901..c735348a2 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -166,7 +166,7 @@ void *tcg_malloc_internal(TCGContext *s, int size)
if (size > TCG_POOL_CHUNK_SIZE) {
/* big malloc: insert a new pool (XXX: could optimize) */
- p = qemu_malloc(sizeof(TCGPool) + size);
+ p = g_malloc(sizeof(TCGPool) + size);
p->size = size;
if (s->pool_current)
s->pool_current->next = p;
@@ -183,7 +183,7 @@ void *tcg_malloc_internal(TCGContext *s, int size)
if (!p->next) {
new_pool:
pool_size = TCG_POOL_CHUNK_SIZE;
- p = qemu_malloc(sizeof(TCGPool) + pool_size);
+ p = g_malloc(sizeof(TCGPool) + pool_size);
p->size = pool_size;
p->next = NULL;
if (s->pool_current)
@@ -227,8 +227,8 @@ void tcg_context_init(TCGContext *s)
total_args += n;
}
- args_ct = qemu_malloc(sizeof(TCGArgConstraint) * total_args);
- sorted_args = qemu_malloc(sizeof(int) * total_args);
+ args_ct = g_malloc(sizeof(TCGArgConstraint) * total_args);
+ sorted_args = g_malloc(sizeof(int) * total_args);
for(op = 0; op < NB_OPS; op++) {
def = &tcg_op_defs[op];
diff --git a/test-qmp-commands.c b/test-qmp-commands.c
index 775290439..f142cc616 100644
--- a/test-qmp-commands.c
+++ b/test-qmp-commands.c
@@ -15,15 +15,15 @@ void qmp_user_def_cmd1(UserDefOne * ud1, Error **errp)
UserDefTwo * qmp_user_def_cmd2(UserDefOne * ud1a, UserDefOne * ud1b, Error **errp)
{
UserDefTwo *ret;
- UserDefOne *ud1c = qemu_mallocz(sizeof(UserDefOne));
- UserDefOne *ud1d = qemu_mallocz(sizeof(UserDefOne));
+ UserDefOne *ud1c = g_malloc0(sizeof(UserDefOne));
+ UserDefOne *ud1d = g_malloc0(sizeof(UserDefOne));
ud1c->string = strdup(ud1a->string);
ud1c->integer = ud1a->integer;
ud1d->string = strdup(ud1b->string);
ud1d->integer = ud1b->integer;
- ret = qemu_mallocz(sizeof(UserDefTwo));
+ ret = g_malloc0(sizeof(UserDefTwo));
ret->string = strdup("blah1");
ret->dict.string = strdup("blah2");
ret->dict.dict.userdef = ud1c;
diff --git a/test-visitor.c b/test-visitor.c
index 5133ad6b1..b7717deb6 100644
--- a/test-visitor.c
+++ b/test-visitor.c
@@ -191,11 +191,11 @@ static void test_nested_structs(void)
g_assert(!g_strcmp0(ud1c_p->string, ud1_p->string));
g_assert(!g_strcmp0(ud2c_p->dict.dict2.string, ud2.dict.dict2.string));
- qemu_free(ud1.string);
- qemu_free(ud2.string);
- qemu_free(ud2.dict.string);
- qemu_free(ud2.dict.dict.string);
- qemu_free(ud2.dict.dict2.string);
+ g_free(ud1.string);
+ g_free(ud2.string);
+ g_free(ud2.dict.string);
+ g_free(ud2.dict.dict.string);
+ g_free(ud2.dict.dict2.string);
qapi_free_UserDefTwo(ud2c_p);
@@ -251,7 +251,7 @@ static void test_nested_enums(void)
QObject *obj;
QString *str;
- nested_enums = qemu_mallocz(sizeof(NestedEnumsOne));
+ nested_enums = g_malloc0(sizeof(NestedEnumsOne));
nested_enums->enum1 = ENUM_ONE_VALUE1;
nested_enums->enum2 = ENUM_ONE_VALUE2;
nested_enums->enum3 = ENUM_ONE_VALUE3;
diff --git a/tests/qruncom.c b/tests/qruncom.c
index 079f7a297..2e93aafb8 100644
--- a/tests/qruncom.c
+++ b/tests/qruncom.c
@@ -44,20 +44,20 @@ static void set_idt(int n, unsigned int dpl)
set_gate(idt_table + n, 0, dpl, 0, 0);
}
-void qemu_free(void *ptr)
+void g_free(void *ptr)
{
free(ptr);
}
-void *qemu_malloc(size_t size)
+void *g_malloc(size_t size)
{
return malloc(size);
}
-void *qemu_mallocz(size_t size)
+void *g_malloc0(size_t size)
{
void *ptr;
- ptr = qemu_malloc(size);
+ ptr = g_malloc(size);
if (!ptr)
return NULL;
memset(ptr, 0, size);
diff --git a/ui/curses.c b/ui/curses.c
index d29b6cf87..c2be2c641 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -354,7 +354,7 @@ void curses_display_init(DisplayState *ds, int full_screen)
#endif
#endif
- dcl = (DisplayChangeListener *) qemu_mallocz(sizeof(DisplayChangeListener));
+ dcl = (DisplayChangeListener *) g_malloc0(sizeof(DisplayChangeListener));
dcl->dpy_update = curses_update;
dcl->dpy_resize = curses_resize;
dcl->dpy_refresh = curses_refresh;
diff --git a/ui/keymaps.c b/ui/keymaps.c
index 78c7ea375..81003bb5c 100644
--- a/ui/keymaps.c
+++ b/ui/keymaps.c
@@ -52,7 +52,7 @@ static void add_to_key_range(struct key_range **krp, int code) {
}
}
if (kr == NULL) {
- kr = qemu_mallocz(sizeof(*kr));
+ kr = g_malloc0(sizeof(*kr));
kr->start = kr->end = code;
kr->next = *krp;
*krp = kr;
@@ -94,13 +94,13 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
if (!k)
- k = qemu_mallocz(sizeof(kbd_layout_t));
+ k = g_malloc0(sizeof(kbd_layout_t));
if (!(filename && (f = fopen(filename, "r")))) {
fprintf(stderr,
"Could not read keymap file: '%s'\n", language);
return NULL;
}
- qemu_free(filename);
+ g_free(filename);
for(;;) {
if (fgets(line, 1024, f) == NULL)
break;
diff --git a/ui/sdl.c b/ui/sdl.c
index 30cde8662..385cc9127 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -166,7 +166,7 @@ static PixelFormat sdl_to_qemu_pixelformat(SDL_PixelFormat *sdl_pf)
static DisplaySurface* sdl_create_displaysurface(int width, int height)
{
- DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
+ DisplaySurface *surface = (DisplaySurface*) g_malloc0(sizeof(DisplaySurface));
if (surface == NULL) {
fprintf(stderr, "sdl_create_displaysurface: malloc failed\n");
exit(1);
@@ -215,8 +215,8 @@ static void sdl_free_displaysurface(DisplaySurface *surface)
return;
if (surface->flags & QEMU_ALLOCATED_FLAG)
- qemu_free(surface->data);
- qemu_free(surface);
+ g_free(surface->data);
+ g_free(surface);
}
static DisplaySurface* sdl_resize_displaysurface(DisplaySurface *surface, int width, int height)
@@ -928,14 +928,14 @@ static void sdl_mouse_define(QEMUCursor *c)
SDL_FreeCursor(guest_sprite);
bpl = cursor_get_mono_bpl(c);
- image = qemu_mallocz(bpl * c->height);
- mask = qemu_mallocz(bpl * c->height);
+ image = g_malloc0(bpl * c->height);
+ mask = g_malloc0(bpl * c->height);
cursor_get_mono_image(c, 0x000000, image);
cursor_get_mono_mask(c, 0, mask);
guest_sprite = SDL_CreateCursor(image, mask, c->width, c->height,
c->hot_x, c->hot_y);
- qemu_free(image);
- qemu_free(mask);
+ g_free(image);
+ g_free(mask);
if (guest_cursor &&
(gui_grab || kbd_mouse_is_absolute() || absolute_enabled))
@@ -1009,7 +1009,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
SDL_WM_SetIcon(image, NULL);
}
- qemu_free(filename);
+ g_free(filename);
}
if (full_screen) {
@@ -1017,7 +1017,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
sdl_grab_start();
}
- dcl = qemu_mallocz(sizeof(DisplayChangeListener));
+ dcl = g_malloc0(sizeof(DisplayChangeListener));
dcl->dpy_update = sdl_update;
dcl->dpy_resize = sdl_resize;
dcl->dpy_refresh = sdl_refresh;
@@ -1027,7 +1027,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
ds->cursor_define = sdl_mouse_define;
register_displaychangelistener(ds, dcl);
- da = qemu_mallocz(sizeof(DisplayAllocator));
+ da = g_malloc0(sizeof(DisplayAllocator));
da->create_displaysurface = sdl_create_displaysurface;
da->resize_displaysurface = sdl_resize_displaysurface;
da->free_displaysurface = sdl_free_displaysurface;
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 8bb62eaa0..dba11f0c3 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -54,7 +54,7 @@ static SpiceTimer *timer_add(SpiceTimerFunc func, void *opaque)
{
SpiceTimer *timer;
- timer = qemu_mallocz(sizeof(*timer));
+ timer = g_malloc0(sizeof(*timer));
timer->timer = qemu_new_timer_ms(rt_clock, func, opaque);
QTAILQ_INSERT_TAIL(&timers, timer, next);
return timer;
@@ -75,7 +75,7 @@ static void timer_remove(SpiceTimer *timer)
qemu_del_timer(timer->timer);
qemu_free_timer(timer->timer);
QTAILQ_REMOVE(&timers, timer, next);
- qemu_free(timer);
+ g_free(timer);
}
struct SpiceWatch {
@@ -118,7 +118,7 @@ static SpiceWatch *watch_add(int fd, int event_mask, SpiceWatchFunc func, void *
{
SpiceWatch *watch;
- watch = qemu_mallocz(sizeof(*watch));
+ watch = g_malloc0(sizeof(*watch));
watch->fd = fd;
watch->func = func;
watch->opaque = opaque;
@@ -132,7 +132,7 @@ static void watch_remove(SpiceWatch *watch)
{
watch_update_mask(watch, 0);
QTAILQ_REMOVE(&watches, watch, next);
- qemu_free(watch);
+ g_free(watch);
}
#if SPICE_INTERFACE_CORE_MINOR >= 3
@@ -148,7 +148,7 @@ static void channel_list_add(SpiceChannelEventInfo *info)
{
ChannelList *item;
- item = qemu_mallocz(sizeof(*item));
+ item = g_malloc0(sizeof(*item));
item->info = info;
QTAILQ_INSERT_TAIL(&channel_list, item, link);
}
@@ -162,7 +162,7 @@ static void channel_list_del(SpiceChannelEventInfo *info)
continue;
}
QTAILQ_REMOVE(&channel_list, item, link);
- qemu_free(item);
+ g_free(item);
return;
}
}
@@ -510,25 +510,25 @@ void qemu_spice_init(void)
str = qemu_opt_get(opts, "x509-key-file");
if (str) {
- x509_key_file = qemu_strdup(str);
+ x509_key_file = g_strdup(str);
} else {
- x509_key_file = qemu_malloc(len);
+ x509_key_file = g_malloc(len);
snprintf(x509_key_file, len, "%s/%s", x509_dir, X509_SERVER_KEY_FILE);
}
str = qemu_opt_get(opts, "x509-cert-file");
if (str) {
- x509_cert_file = qemu_strdup(str);
+ x509_cert_file = g_strdup(str);
} else {
- x509_cert_file = qemu_malloc(len);
+ x509_cert_file = g_malloc(len);
snprintf(x509_cert_file, len, "%s/%s", x509_dir, X509_SERVER_CERT_FILE);
}
str = qemu_opt_get(opts, "x509-cacert-file");
if (str) {
- x509_cacert_file = qemu_strdup(str);
+ x509_cacert_file = g_strdup(str);
} else {
- x509_cacert_file = qemu_malloc(len);
+ x509_cacert_file = g_malloc(len);
snprintf(x509_cacert_file, len, "%s/%s", x509_dir, X509_CA_CERT_FILE);
}
@@ -631,9 +631,9 @@ void qemu_spice_init(void)
qemu_spice_input_init();
qemu_spice_audio_init();
- qemu_free(x509_key_file);
- qemu_free(x509_cert_file);
- qemu_free(x509_cacert_file);
+ g_free(x509_key_file);
+ g_free(x509_cert_file);
+ g_free(x509_cacert_file);
}
int qemu_spice_add_interface(SpiceBaseInstance *sin)
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 683d45429..498396332 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -144,14 +144,14 @@ static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
ssd->dirty.left, ssd->dirty.right,
ssd->dirty.top, ssd->dirty.bottom);
- update = qemu_mallocz(sizeof(*update));
+ update = g_malloc0(sizeof(*update));
drawable = &update->drawable;
image = &update->image;
cmd = &update->ext.cmd;
bw = ssd->dirty.right - ssd->dirty.left;
bh = ssd->dirty.bottom - ssd->dirty.top;
- update->bitmap = qemu_malloc(bw * bh * 4);
+ update->bitmap = g_malloc(bw * bh * 4);
drawable->bbox = ssd->dirty;
drawable->clip.type = SPICE_CLIP_TYPE_NONE;
@@ -208,12 +208,12 @@ static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
* Called from spice server thread context (via interface_release_ressource)
* We do *not* hold the global qemu mutex here, so extra care is needed
* when calling qemu functions. Qemu interfaces used:
- * - qemu_free (underlying glibc free is re-entrant).
+ * - g_free (underlying glibc free is re-entrant).
*/
void qemu_spice_destroy_update(SimpleSpiceDisplay *sdpy, SimpleSpiceUpdate *update)
{
- qemu_free(update->bitmap);
- qemu_free(update);
+ g_free(update->bitmap);
+ g_free(update);
}
void qemu_spice_create_host_memslot(SimpleSpiceDisplay *ssd)
@@ -274,7 +274,7 @@ void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
ssd->mouse_x = -1;
ssd->mouse_y = -1;
ssd->bufsize = (16 * 1024 * 1024);
- ssd->buf = qemu_malloc(ssd->bufsize);
+ ssd->buf = g_malloc(ssd->bufsize);
}
/* display listener callbacks */
diff --git a/ui/spice-input.c b/ui/spice-input.c
index 75abf5fbe..af4223d44 100644
--- a/ui/spice-input.c
+++ b/ui/spice-input.c
@@ -200,12 +200,12 @@ void qemu_spice_input_init(void)
QemuSpiceKbd *kbd;
QemuSpicePointer *pointer;
- kbd = qemu_mallocz(sizeof(*kbd));
+ kbd = g_malloc0(sizeof(*kbd));
kbd->sin.base.sif = &kbd_interface.base;
qemu_spice_add_interface(&kbd->sin.base);
qemu_add_led_event_handler(kbd_leds, kbd);
- pointer = qemu_mallocz(sizeof(*pointer));
+ pointer = g_malloc0(sizeof(*pointer));
pointer->mouse.base.sif = &mouse_interface.base;
pointer->tablet.base.sif = &tablet_interface.base;
qemu_spice_add_interface(&pointer->mouse.base);
diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c
index 15af49bdb..e96095ab9 100644
--- a/ui/vnc-auth-sasl.c
+++ b/ui/vnc-auth-sasl.c
@@ -135,7 +135,7 @@ static int vnc_auth_sasl_check_access(VncState *vs)
}
VNC_DEBUG("SASL client username %s\n", (const char *)val);
- vs->sasl.username = qemu_strdup((const char*)val);
+ vs->sasl.username = g_strdup((const char*)val);
if (vs->vd->sasl.acl == NULL) {
VNC_DEBUG("no ACL activated, allowing access\n");
diff --git a/ui/vnc-enc-hextile.c b/ui/vnc-enc-hextile.c
index 364a49115..d2905c88f 100644
--- a/ui/vnc-enc-hextile.c
+++ b/ui/vnc-enc-hextile.c
@@ -70,8 +70,8 @@ int vnc_hextile_send_framebuffer_update(VncState *vs, int x,
uint8_t *last_fg, *last_bg;
VncDisplay *vd = vs->vd;
- last_fg = (uint8_t *) qemu_malloc(vd->server->pf.bytes_per_pixel);
- last_bg = (uint8_t *) qemu_malloc(vd->server->pf.bytes_per_pixel);
+ last_fg = (uint8_t *) g_malloc(vd->server->pf.bytes_per_pixel);
+ last_bg = (uint8_t *) g_malloc(vd->server->pf.bytes_per_pixel);
has_fg = has_bg = 0;
for (j = y; j < (y + h); j += 16) {
for (i = x; i < (x + w); i += 16) {
diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 5c0280341..5d492abe9 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -1293,13 +1293,13 @@ static int send_jpeg_rect(VncState *vs, int x, int y, int w, int h, int quality)
jpeg_start_compress(&cinfo, true);
- buf = qemu_malloc(w * 3);
+ buf = g_malloc(w * 3);
row[0] = buf;
for (dy = 0; dy < h; dy++) {
rgb_prepare_row(vs, buf, x, y + dy, w);
jpeg_write_scanlines(&cinfo, row, 1);
}
- qemu_free(buf);
+ g_free(buf);
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
@@ -1363,12 +1363,12 @@ static void png_flush_data(png_structp png_ptr)
static void *vnc_png_malloc(png_structp png_ptr, png_size_t size)
{
- return qemu_malloc(size);
+ return g_malloc(size);
}
static void vnc_png_free(png_structp png_ptr, png_voidp ptr)
{
- qemu_free(ptr);
+ g_free(ptr);
}
static int send_png_rect(VncState *vs, int x, int y, int w, int h,
@@ -1432,7 +1432,7 @@ static int send_png_rect(VncState *vs, int x, int y, int w, int h,
png_write_info(png_ptr, info_ptr);
buffer_reserve(&vs->tight.png, 2048);
- buf = qemu_malloc(w * 3);
+ buf = g_malloc(w * 3);
for (dy = 0; dy < h; dy++)
{
if (color_type == PNG_COLOR_TYPE_PALETTE) {
@@ -1442,7 +1442,7 @@ static int send_png_rect(VncState *vs, int x, int y, int w, int h,
}
png_write_row(png_ptr, buf);
}
- qemu_free(buf);
+ g_free(buf);
png_write_end(png_ptr, NULL);
diff --git a/ui/vnc-enc-zlib.c b/ui/vnc-enc-zlib.c
index e32e4cd8a..d1b97f251 100644
--- a/ui/vnc-enc-zlib.c
+++ b/ui/vnc-enc-zlib.c
@@ -35,14 +35,14 @@ void *vnc_zlib_zalloc(void *x, unsigned items, unsigned size)
size *= items;
size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1);
- p = qemu_mallocz(size);
+ p = g_malloc0(size);
return (p);
}
void vnc_zlib_zfree(void *x, void *addr)
{
- qemu_free(addr);
+ g_free(addr);
}
static void vnc_zlib_start(VncState *vs)
diff --git a/ui/vnc-jobs-async.c b/ui/vnc-jobs-async.c
index 1dfa6c3c9..de5ea6b5d 100644
--- a/ui/vnc-jobs-async.c
+++ b/ui/vnc-jobs-async.c
@@ -77,7 +77,7 @@ static void vnc_unlock_queue(VncJobQueue *queue)
VncJob *vnc_job_new(VncState *vs)
{
- VncJob *job = qemu_mallocz(sizeof(VncJob));
+ VncJob *job = g_malloc0(sizeof(VncJob));
job->vs = vs;
vnc_lock_queue(queue);
@@ -88,7 +88,7 @@ VncJob *vnc_job_new(VncState *vs)
int vnc_job_add_rect(VncJob *job, int x, int y, int w, int h)
{
- VncRectEntry *entry = qemu_mallocz(sizeof(VncRectEntry));
+ VncRectEntry *entry = g_malloc0(sizeof(VncRectEntry));
entry->rect.x = x;
entry->rect.y = y;
@@ -105,7 +105,7 @@ void vnc_job_push(VncJob *job)
{
vnc_lock_queue(queue);
if (queue->exit || QLIST_EMPTY(&job->rectangles)) {
- qemu_free(job);
+ g_free(job);
} else {
QTAILQ_INSERT_TAIL(&queue->jobs, job, next);
qemu_cond_broadcast(&queue->cond);
@@ -246,7 +246,7 @@ static int vnc_worker_thread_loop(VncJobQueue *queue)
if (n >= 0) {
n_rectangles += n;
}
- qemu_free(entry);
+ g_free(entry);
}
vnc_unlock_display(job->vs->vd);
@@ -276,13 +276,13 @@ disconnected:
QTAILQ_REMOVE(&queue->jobs, job, next);
vnc_unlock_queue(queue);
qemu_cond_broadcast(&queue->cond);
- qemu_free(job);
+ g_free(job);
return 0;
}
static VncJobQueue *vnc_queue_init(void)
{
- VncJobQueue *queue = qemu_mallocz(sizeof(VncJobQueue));
+ VncJobQueue *queue = g_malloc0(sizeof(VncJobQueue));
qemu_cond_init(&queue->cond);
qemu_mutex_init(&queue->mutex);
@@ -295,7 +295,7 @@ static void vnc_queue_clear(VncJobQueue *q)
qemu_cond_destroy(&queue->cond);
qemu_mutex_destroy(&queue->mutex);
buffer_free(&queue->buffer);
- qemu_free(q);
+ g_free(q);
queue = NULL; /* Unset global queue */
}
diff --git a/ui/vnc-palette.c b/ui/vnc-palette.c
index 13ece4216..63d5f6491 100644
--- a/ui/vnc-palette.c
+++ b/ui/vnc-palette.c
@@ -55,7 +55,7 @@ VncPalette *palette_new(size_t max, int bpp)
{
VncPalette *palette;
- palette = qemu_mallocz(sizeof(*palette));
+ palette = g_malloc0(sizeof(*palette));
palette_init(palette, max, bpp);
return palette;
}
@@ -69,7 +69,7 @@ void palette_init(VncPalette *palette, size_t max, int bpp)
void palette_destroy(VncPalette *palette)
{
- qemu_free(palette);
+ g_free(palette);
}
int palette_put(VncPalette *palette, uint32_t color)
diff --git a/ui/vnc-tls.c b/ui/vnc-tls.c
index 31f1467ad..2e2456e3a 100644
--- a/ui/vnc-tls.c
+++ b/ui/vnc-tls.c
@@ -244,11 +244,11 @@ int vnc_tls_validate_certificate(struct VncState *vs)
if (i == 0) {
size_t dnameSize = 1024;
- vs->tls.dname = qemu_malloc(dnameSize);
+ vs->tls.dname = g_malloc(dnameSize);
requery:
if ((ret = gnutls_x509_crt_get_dn (cert, vs->tls.dname, &dnameSize)) != 0) {
if (ret == GNUTLS_E_SHORT_MEMORY_BUFFER) {
- vs->tls.dname = qemu_realloc(vs->tls.dname, dnameSize);
+ vs->tls.dname = g_realloc(vs->tls.dname, dnameSize);
goto requery;
}
gnutls_x509_crt_deinit (cert);
@@ -397,11 +397,11 @@ static int vnc_set_x509_credential(VncDisplay *vd,
struct stat sb;
if (*cred) {
- qemu_free(*cred);
+ g_free(*cred);
*cred = NULL;
}
- *cred = qemu_malloc(strlen(certdir) + strlen(filename) + 2);
+ *cred = g_malloc(strlen(certdir) + strlen(filename) + 2);
strcpy(*cred, certdir);
strcat(*cred, "/");
@@ -409,7 +409,7 @@ static int vnc_set_x509_credential(VncDisplay *vd,
VNC_DEBUG("Check %s\n", *cred);
if (stat(*cred, &sb) < 0) {
- qemu_free(*cred);
+ g_free(*cred);
*cred = NULL;
if (ignoreMissing && errno == ENOENT)
return 0;
@@ -435,10 +435,10 @@ int vnc_tls_set_x509_creds_dir(VncDisplay *vd,
return 0;
cleanup:
- qemu_free(vd->tls.x509cacert);
- qemu_free(vd->tls.x509cacrl);
- qemu_free(vd->tls.x509cert);
- qemu_free(vd->tls.x509key);
+ g_free(vd->tls.x509cacert);
+ g_free(vd->tls.x509cacrl);
+ g_free(vd->tls.x509cert);
+ g_free(vd->tls.x509key);
vd->tls.x509cacert = vd->tls.x509cacrl = vd->tls.x509cert = vd->tls.x509key = NULL;
return -1;
}
diff --git a/ui/vnc.c b/ui/vnc.c
index f1e27d97b..fc3a612a3 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -67,7 +67,7 @@ static char *addr_to_string(const char *format,
/* Enough for the existing format + the 2 vars we're
* substituting in. */
addrlen = strlen(format) + strlen(host) + strlen(serv);
- addr = qemu_malloc(addrlen + 1);
+ addr = g_malloc(addrlen + 1);
snprintf(addr, addrlen, format, host, serv);
addr[addrlen] = '\0';
@@ -411,7 +411,7 @@ void buffer_reserve(Buffer *buffer, size_t len)
{
if ((buffer->capacity - buffer->offset) < len) {
buffer->capacity += (len + 1024);
- buffer->buffer = qemu_realloc(buffer->buffer, buffer->capacity);
+ buffer->buffer = g_realloc(buffer->buffer, buffer->capacity);
if (buffer->buffer == NULL) {
fprintf(stderr, "vnc: out of memory\n");
exit(1);
@@ -436,7 +436,7 @@ void buffer_reset(Buffer *buffer)
void buffer_free(Buffer *buffer)
{
- qemu_free(buffer->buffer);
+ g_free(buffer->buffer);
buffer->offset = 0;
buffer->capacity = 0;
buffer->buffer = NULL;
@@ -505,16 +505,16 @@ static void vnc_dpy_resize(DisplayState *ds)
/* server surface */
if (!vd->server)
- vd->server = qemu_mallocz(sizeof(*vd->server));
+ vd->server = g_malloc0(sizeof(*vd->server));
if (vd->server->data)
- qemu_free(vd->server->data);
+ g_free(vd->server->data);
*(vd->server) = *(ds->surface);
- vd->server->data = qemu_mallocz(vd->server->linesize *
+ vd->server->data = g_malloc0(vd->server->linesize *
vd->server->height);
/* guest surface */
if (!vd->guest.ds)
- vd->guest.ds = qemu_mallocz(sizeof(*vd->guest.ds));
+ vd->guest.ds = g_malloc0(sizeof(*vd->guest.ds));
if (ds_get_bytes_per_pixel(ds) != vd->guest.ds->pf.bytes_per_pixel)
console_color_init(ds);
*(vd->guest.ds) = *(ds->surface);
@@ -781,12 +781,12 @@ static void vnc_dpy_cursor_define(QEMUCursor *c)
VncState *vs;
cursor_put(vd->cursor);
- qemu_free(vd->cursor_mask);
+ g_free(vd->cursor_mask);
vd->cursor = c;
cursor_get(vd->cursor);
vd->cursor_msize = cursor_get_mono_bpl(c) * c->height;
- vd->cursor_mask = qemu_mallocz(vd->cursor_msize);
+ vd->cursor_mask = g_malloc0(vd->cursor_msize);
cursor_get_mono_mask(c, 0, vd->cursor_mask);
QTAILQ_FOREACH(vs, &vd->clients, next) {
@@ -1013,10 +1013,10 @@ static void vnc_disconnect_finish(VncState *vs)
qemu_mutex_destroy(&vs->output_mutex);
#endif
for (i = 0; i < VNC_STAT_ROWS; ++i) {
- qemu_free(vs->lossy_rect[i]);
+ g_free(vs->lossy_rect[i]);
}
- qemu_free(vs->lossy_rect);
- qemu_free(vs);
+ g_free(vs->lossy_rect);
+ g_free(vs);
}
int vnc_client_io_error(VncState *vs, int ret, int last_errno)
@@ -2496,7 +2496,7 @@ static void vnc_remove_timer(VncDisplay *vd)
static void vnc_connect(VncDisplay *vd, int csock, int skipauth)
{
- VncState *vs = qemu_mallocz(sizeof(VncState));
+ VncState *vs = g_malloc0(sizeof(VncState));
int i;
vs->csock = csock;
@@ -2513,9 +2513,9 @@ static void vnc_connect(VncDisplay *vd, int csock, int skipauth)
#endif
}
- vs->lossy_rect = qemu_mallocz(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));
+ vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));
for (i = 0; i < VNC_STAT_ROWS; ++i) {
- vs->lossy_rect[i] = qemu_mallocz(VNC_STAT_COLS * sizeof (uint8_t));
+ vs->lossy_rect[i] = g_malloc0(VNC_STAT_COLS * sizeof (uint8_t));
}
VNC_DEBUG("New client on socket %d\n", csock);
@@ -2576,9 +2576,9 @@ static void vnc_listen_read(void *opaque)
void vnc_display_init(DisplayState *ds)
{
- VncDisplay *vs = qemu_mallocz(sizeof(*vs));
+ VncDisplay *vs = g_malloc0(sizeof(*vs));
- dcl = qemu_mallocz(sizeof(DisplayChangeListener));
+ dcl = g_malloc0(sizeof(DisplayChangeListener));
ds->opaque = vs;
dcl->idle = 1;
@@ -2620,7 +2620,7 @@ void vnc_display_close(DisplayState *ds)
if (!vs)
return;
if (vs->display) {
- qemu_free(vs->display);
+ g_free(vs->display);
vs->display = NULL;
}
if (vs->lsock != -1) {
@@ -2644,7 +2644,7 @@ int vnc_display_disable_login(DisplayState *ds)
}
if (vs->password) {
- qemu_free(vs->password);
+ g_free(vs->password);
}
vs->password = NULL;
@@ -2671,10 +2671,10 @@ int vnc_display_password(DisplayState *ds, const char *password)
}
if (vs->password) {
- qemu_free(vs->password);
+ g_free(vs->password);
vs->password = NULL;
}
- vs->password = qemu_strdup(password);
+ vs->password = g_strdup(password);
vs->auth = VNC_AUTH_VNC;
out:
if (ret != 0) {
@@ -2753,20 +2753,20 @@ int vnc_display_open(DisplayState *ds, const char *display)
end = strchr(options, ',');
if (start && (!end || (start < end))) {
int len = end ? end-(start+1) : strlen(start+1);
- char *path = qemu_strndup(start + 1, len);
+ char *path = g_strndup(start + 1, len);
VNC_DEBUG("Trying certificate path '%s'\n", path);
if (vnc_tls_set_x509_creds_dir(vs, path) < 0) {
fprintf(stderr, "Failed to find x509 certificates/keys in %s\n", path);
- qemu_free(path);
- qemu_free(vs->display);
+ g_free(path);
+ g_free(vs->display);
vs->display = NULL;
return -1;
}
- qemu_free(path);
+ g_free(path);
} else {
fprintf(stderr, "No certificate path provided\n");
- qemu_free(vs->display);
+ g_free(vs->display);
vs->display = NULL;
return -1;
}
@@ -2907,7 +2907,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
} else {
/* listen for connects */
char *dpy;
- dpy = qemu_malloc(256);
+ dpy = g_malloc(256);
if (strncmp(display, "unix:", 5) == 0) {
pstrcpy(dpy, 256, "unix:");
vs->lsock = unix_listen(display+5, dpy+5, 256-5);
diff --git a/usb-bsd.c b/usb-bsd.c
index ab84d9385..11875527d 100644
--- a/usb-bsd.c
+++ b/usb-bsd.c
@@ -290,7 +290,7 @@ static void usb_host_handle_destroy(USBDevice *opaque)
close(s->devfd);
- qemu_free(s);
+ g_free(s);
}
static int usb_host_initfn(USBDevice *dev)
diff --git a/usb-linux.c b/usb-linux.c
index 5562187bd..2e20f8e93 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -271,7 +271,7 @@ struct AsyncURB
static AsyncURB *async_alloc(USBHostDevice *s)
{
- AsyncURB *aurb = qemu_mallocz(sizeof(AsyncURB));
+ AsyncURB *aurb = g_malloc0(sizeof(AsyncURB));
aurb->hdev = s;
QLIST_INSERT_HEAD(&s->aurbs, aurb, next);
return aurb;
@@ -280,7 +280,7 @@ static AsyncURB *async_alloc(USBHostDevice *s)
static void async_free(AsyncURB *aurb)
{
QLIST_REMOVE(aurb, next);
- qemu_free(aurb);
+ g_free(aurb);
}
static void do_disconnect(USBHostDevice *s)
@@ -528,11 +528,11 @@ static AsyncURB *usb_host_alloc_iso(USBHostDevice *s, uint8_t ep, int in)
AsyncURB *aurb;
int i, j, len = get_max_packet_size(s, ep);
- aurb = qemu_mallocz(s->iso_urb_count * sizeof(*aurb));
+ aurb = g_malloc0(s->iso_urb_count * sizeof(*aurb));
for (i = 0; i < s->iso_urb_count; i++) {
aurb[i].urb.endpoint = ep;
aurb[i].urb.buffer_length = ISO_FRAME_DESC_PER_URB * len;
- aurb[i].urb.buffer = qemu_malloc(aurb[i].urb.buffer_length);
+ aurb[i].urb.buffer = g_malloc(aurb[i].urb.buffer_length);
aurb[i].urb.type = USBDEVFS_URB_TYPE_ISO;
aurb[i].urb.flags = USBDEVFS_URB_ISO_ASAP;
aurb[i].urb.number_of_packets = ISO_FRAME_DESC_PER_URB;
@@ -578,11 +578,11 @@ static void usb_host_stop_n_free_iso(USBHostDevice *s, uint8_t ep)
}
for (i = 0; i < s->iso_urb_count; i++) {
- qemu_free(aurb[i].urb.buffer);
+ g_free(aurb[i].urb.buffer);
}
if (free)
- qemu_free(aurb);
+ g_free(aurb);
else
printf("husb: leaking iso urbs because of discard failure\n");
set_iso_urb(s, ep, NULL);
@@ -1688,7 +1688,7 @@ static int usb_host_scan(void *opaque, USBScanFunc *func)
}
/* the module setting (used later for opening devices) */
- usb_host_device_path = qemu_mallocz(strlen(devpath)+1);
+ usb_host_device_path = g_malloc0(strlen(devpath)+1);
strcpy(usb_host_device_path, devpath);
if (mon) {
monitor_printf(mon, "husb: using %s file-system with %s\n",
diff --git a/usb-redir.c b/usb-redir.c
index 9e5fce21e..3fbbcfff9 100644
--- a/usb-redir.c
+++ b/usb-redir.c
@@ -234,7 +234,7 @@ static int usbredir_write(void *priv, uint8_t *data, int count)
static AsyncURB *async_alloc(USBRedirDevice *dev, USBPacket *p)
{
- AsyncURB *aurb = (AsyncURB *) qemu_mallocz(sizeof(AsyncURB));
+ AsyncURB *aurb = (AsyncURB *) g_malloc0(sizeof(AsyncURB));
aurb->dev = dev;
aurb->packet = p;
aurb->packet_id = dev->packet_id;
@@ -247,7 +247,7 @@ static AsyncURB *async_alloc(USBRedirDevice *dev, USBPacket *p)
static void async_free(USBRedirDevice *dev, AsyncURB *aurb)
{
QTAILQ_REMOVE(&dev->asyncq, aurb, next);
- qemu_free(aurb);
+ g_free(aurb);
}
static AsyncURB *async_find(USBRedirDevice *dev, uint32_t packet_id)
@@ -286,7 +286,7 @@ static void usbredir_cancel_packet(USBDevice *udev, USBPacket *p)
static struct buf_packet *bufp_alloc(USBRedirDevice *dev,
uint8_t *data, int len, int status, uint8_t ep)
{
- struct buf_packet *bufp = qemu_malloc(sizeof(struct buf_packet));
+ struct buf_packet *bufp = g_malloc(sizeof(struct buf_packet));
bufp->data = data;
bufp->len = len;
bufp->status = status;
@@ -299,7 +299,7 @@ static void bufp_free(USBRedirDevice *dev, struct buf_packet *bufp,
{
QTAILQ_REMOVE(&dev->endpoint[EP2I(ep)].bufpq, bufp, next);
free(bufp->data);
- qemu_free(bufp);
+ g_free(bufp);
}
static void usbredir_free_bufpq(USBRedirDevice *dev, uint8_t ep)
diff --git a/vl.c b/vl.c
index d1971df4a..84054295f 100644
--- a/vl.c
+++ b/vl.c
@@ -300,7 +300,7 @@ static struct {
static void res_free(void)
{
if (boot_splash_filedata != NULL) {
- qemu_free(boot_splash_filedata);
+ g_free(boot_splash_filedata);
boot_splash_filedata = NULL;
}
}
@@ -466,7 +466,7 @@ static struct bt_scatternet_s *qemu_find_bt_vlan(int id)
if (vlan->id == id)
return &vlan->net;
}
- vlan = qemu_mallocz(sizeof(struct bt_vlan_s));
+ vlan = g_malloc0(sizeof(struct bt_vlan_s));
vlan->id = id;
pvlan = &first_bt_vlan;
while (*pvlan != NULL)
@@ -741,7 +741,7 @@ static void restore_boot_devices(void *opaque)
qemu_boot_set(standard_boot_devices);
qemu_unregister_reset(restore_boot_devices, standard_boot_devices);
- qemu_free(standard_boot_devices);
+ g_free(standard_boot_devices);
}
void add_boot_device_path(int32_t bootindex, DeviceState *dev,
@@ -755,9 +755,9 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
assert(dev != NULL || suffix != NULL);
- node = qemu_mallocz(sizeof(FWBootEntry));
+ node = g_malloc0(sizeof(FWBootEntry));
node->bootindex = bootindex;
- node->suffix = suffix ? qemu_strdup(suffix) : NULL;
+ node->suffix = suffix ? g_strdup(suffix) : NULL;
node->dev = dev;
QTAILQ_FOREACH(i, &fw_boot_order, link) {
@@ -798,13 +798,13 @@ char *get_boot_devices_list(uint32_t *size)
if (i->suffix && devpath) {
size_t bootpathlen = strlen(devpath) + strlen(i->suffix) + 1;
- bootpath = qemu_malloc(bootpathlen);
+ bootpath = g_malloc(bootpathlen);
snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix);
- qemu_free(devpath);
+ g_free(devpath);
} else if (devpath) {
bootpath = devpath;
} else {
- bootpath = qemu_strdup(i->suffix);
+ bootpath = g_strdup(i->suffix);
assert(bootpath);
}
@@ -812,10 +812,10 @@ char *get_boot_devices_list(uint32_t *size)
list[total-1] = '\n';
}
len = strlen(bootpath) + 1;
- list = qemu_realloc(list, total + len);
+ list = g_realloc(list, total + len);
memcpy(&list[total], bootpath, len);
total += len;
- qemu_free(bootpath);
+ g_free(bootpath);
}
*size = total;
@@ -1014,7 +1014,7 @@ void pcmcia_socket_register(PCMCIASocket *socket)
{
struct pcmcia_socket_entry_s *entry;
- entry = qemu_malloc(sizeof(struct pcmcia_socket_entry_s));
+ entry = g_malloc(sizeof(struct pcmcia_socket_entry_s));
entry->socket = socket;
entry->next = pcmcia_sockets;
pcmcia_sockets = entry;
@@ -1028,7 +1028,7 @@ void pcmcia_socket_unregister(PCMCIASocket *socket)
for (entry = *ptr; entry; ptr = &entry->next, entry = *ptr)
if (entry->socket == socket) {
*ptr = entry->next;
- qemu_free(entry);
+ g_free(entry);
}
}
@@ -1129,7 +1129,7 @@ VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
{
VMChangeStateEntry *e;
- e = qemu_mallocz(sizeof (*e));
+ e = g_malloc0(sizeof (*e));
e->cb = cb;
e->opaque = opaque;
@@ -1140,7 +1140,7 @@ VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
void qemu_del_vm_change_state_handler(VMChangeStateEntry *e)
{
QLIST_REMOVE (e, entries);
- qemu_free (e);
+ g_free (e);
}
void vm_state_notify(int running, int reason)
@@ -1245,7 +1245,7 @@ static int qemu_vmstop_requested(void)
void qemu_register_reset(QEMUResetHandler *func, void *opaque)
{
- QEMUResetEntry *re = qemu_mallocz(sizeof(QEMUResetEntry));
+ QEMUResetEntry *re = g_malloc0(sizeof(QEMUResetEntry));
re->func = func;
re->opaque = opaque;
@@ -1259,7 +1259,7 @@ void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)
QTAILQ_FOREACH(re, &reset_handlers, entry) {
if (re->func == func && re->opaque == opaque) {
QTAILQ_REMOVE(&reset_handlers, re, entry);
- qemu_free(re);
+ g_free(re);
return;
}
}
@@ -1648,7 +1648,7 @@ char *qemu_find_file(int type, const char *name)
/* If name contains path separators then try it as a straight path. */
if ((strchr(name, '/') || strchr(name, '\\'))
&& access(name, R_OK) == 0) {
- return qemu_strdup(name);
+ return g_strdup(name);
}
switch (type) {
case QEMU_FILE_TYPE_BIOS:
@@ -1661,10 +1661,10 @@ char *qemu_find_file(int type, const char *name)
abort();
}
len = strlen(data_dir) + strlen(name) + strlen(subdir) + 2;
- buf = qemu_mallocz(len);
+ buf = g_malloc0(len);
snprintf(buf, len, "%s/%s%s", data_dir, subdir, name);
if (access(buf, R_OK)) {
- qemu_free(buf);
+ g_free(buf);
return NULL;
}
return buf;
@@ -1795,7 +1795,7 @@ static void add_device_config(int type, const char *cmdline)
{
struct device_config *conf;
- conf = qemu_mallocz(sizeof(*conf));
+ conf = g_malloc0(sizeof(*conf));
conf->type = type;
conf->cmdline = cmdline;
QTAILQ_INSERT_TAIL(&device_configs, conf, next);
@@ -2367,7 +2367,7 @@ int main(int argc, char **argv, char **envp)
if (get_param_value(buf, sizeof(buf),
"once", optarg)) {
validate_bootdevices(buf);
- standard_boot_devices = qemu_strdup(boot_devices);
+ standard_boot_devices = g_strdup(boot_devices);
pstrcpy(boot_devices, sizeof(boot_devices), buf);
qemu_register_reset(restore_boot_devices,
standard_boot_devices);
@@ -2808,7 +2808,7 @@ int main(int argc, char **argv, char **envp)
semihosting_enabled = 1;
break;
case QEMU_OPTION_name:
- qemu_name = qemu_strdup(optarg);
+ qemu_name = g_strdup(optarg);
{
char *p = strchr(qemu_name, ',');
if (p != NULL) {
diff --git a/xen-all.c b/xen-all.c
index 9eaeac165..84420d83a 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -140,7 +140,7 @@ static void xen_ram_init(ram_addr_t ram_size)
RAMBlock *new_block;
ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
- new_block = qemu_mallocz(sizeof (*new_block));
+ new_block = g_malloc0(sizeof (*new_block));
pstrcpy(new_block->idstr, sizeof (new_block->idstr), "xen.ram");
new_block->host = NULL;
new_block->offset = 0;
@@ -154,7 +154,7 @@ static void xen_ram_init(ram_addr_t ram_size)
QLIST_INSERT_HEAD(&ram_list.blocks, new_block, next);
- ram_list.phys_dirty = qemu_realloc(ram_list.phys_dirty,
+ ram_list.phys_dirty = g_realloc(ram_list.phys_dirty,
new_block->length >> TARGET_PAGE_BITS);
memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS),
0xff, new_block->length >> TARGET_PAGE_BITS);
@@ -190,7 +190,7 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size)
trace_xen_ram_alloc(ram_addr, size);
nr_pfn = size >> TARGET_PAGE_BITS;
- pfn_list = qemu_malloc(sizeof (*pfn_list) * nr_pfn);
+ pfn_list = g_malloc(sizeof (*pfn_list) * nr_pfn);
for (i = 0; i < nr_pfn; i++) {
pfn_list[i] = (ram_addr >> TARGET_PAGE_BITS) + i;
@@ -200,7 +200,7 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size)
hw_error("xen: failed to populate ram at " RAM_ADDR_FMT, ram_addr);
}
- qemu_free(pfn_list);
+ g_free(pfn_list);
}
static XenPhysmap *get_physmapping(XenIOState *state,
@@ -267,7 +267,7 @@ go_physmap:
}
}
- physmap = qemu_malloc(sizeof (XenPhysmap));
+ physmap = g_malloc(sizeof (XenPhysmap));
physmap->start_addr = start_addr;
physmap->size = size;
@@ -888,7 +888,7 @@ int xen_hvm_init(void)
unsigned long ioreq_pfn;
XenIOState *state;
- state = qemu_mallocz(sizeof (XenIOState));
+ state = g_malloc0(sizeof (XenIOState));
state->xce_handle = xen_xc_evtchn_open(NULL, 0);
if (state->xce_handle == XC_HANDLER_INITIAL_VALUE) {
@@ -922,7 +922,7 @@ int xen_hvm_init(void)
hw_error("map buffered IO page returned error %d", errno);
}
- state->ioreq_local_port = qemu_mallocz(smp_cpus * sizeof (evtchn_port_t));
+ state->ioreq_local_port = g_malloc0(smp_cpus * sizeof (evtchn_port_t));
/* FIXME: how about if we overflow the page here? */
for (i = 0; i < smp_cpus; i++) {
diff --git a/xen-mapcache.c b/xen-mapcache.c
index 15d12413d..5b247ee09 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -87,7 +87,7 @@ void xen_map_cache_init(void)
unsigned long size;
struct rlimit rlimit_as;
- mapcache = qemu_mallocz(sizeof (MapCache));
+ mapcache = g_malloc0(sizeof (MapCache));
QTAILQ_INIT(&mapcache->locked_entries);
mapcache->last_address_index = -1;
@@ -111,7 +111,7 @@ void xen_map_cache_init(void)
size = (size + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1);
DPRINTF("%s, nr_buckets = %lx size %lu\n", __func__,
mapcache->nr_buckets, size);
- mapcache->entry = qemu_mallocz(size);
+ mapcache->entry = g_malloc0(size);
}
static void xen_remap_bucket(MapCacheEntry *entry,
@@ -126,8 +126,8 @@ static void xen_remap_bucket(MapCacheEntry *entry,
trace_xen_remap_bucket(address_index);
- pfns = qemu_mallocz(nb_pfn * sizeof (xen_pfn_t));
- err = qemu_mallocz(nb_pfn * sizeof (int));
+ pfns = g_malloc0(nb_pfn * sizeof (xen_pfn_t));
+ err = g_malloc0(nb_pfn * sizeof (int));
if (entry->vaddr_base != NULL) {
if (munmap(entry->vaddr_base, entry->size) != 0) {
@@ -136,7 +136,7 @@ static void xen_remap_bucket(MapCacheEntry *entry,
}
}
if (entry->valid_mapping != NULL) {
- qemu_free(entry->valid_mapping);
+ g_free(entry->valid_mapping);
entry->valid_mapping = NULL;
}
@@ -154,7 +154,7 @@ static void xen_remap_bucket(MapCacheEntry *entry,
entry->vaddr_base = vaddr_base;
entry->paddr_index = address_index;
entry->size = size;
- entry->valid_mapping = (unsigned long *) qemu_mallocz(sizeof(unsigned long) *
+ entry->valid_mapping = (unsigned long *) g_malloc0(sizeof(unsigned long) *
BITS_TO_LONGS(size >> XC_PAGE_SHIFT));
bitmap_zero(entry->valid_mapping, nb_pfn);
@@ -164,8 +164,8 @@ static void xen_remap_bucket(MapCacheEntry *entry,
}
}
- qemu_free(pfns);
- qemu_free(err);
+ g_free(pfns);
+ g_free(err);
}
uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
@@ -201,7 +201,7 @@ uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
entry = entry->next;
}
if (!entry) {
- entry = qemu_mallocz(sizeof (MapCacheEntry));
+ entry = g_malloc0(sizeof (MapCacheEntry));
pentry->next = entry;
xen_remap_bucket(entry, __size, address_index);
} else if (!entry->lock) {
@@ -223,7 +223,7 @@ uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
mapcache->last_address_index = address_index;
mapcache->last_address_vaddr = entry->vaddr_base;
if (lock) {
- MapCacheRev *reventry = qemu_mallocz(sizeof(MapCacheRev));
+ MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev));
entry->lock++;
reventry->vaddr_req = mapcache->last_address_vaddr + address_offset;
reventry->paddr_index = mapcache->last_address_index;
@@ -301,7 +301,7 @@ void xen_invalidate_map_cache_entry(uint8_t *buffer)
return;
}
QTAILQ_REMOVE(&mapcache->locked_entries, reventry, next);
- qemu_free(reventry);
+ g_free(reventry);
entry = &mapcache->entry[paddr_index % mapcache->nr_buckets];
while (entry && (entry->paddr_index != paddr_index || entry->size != size)) {
@@ -322,8 +322,8 @@ void xen_invalidate_map_cache_entry(uint8_t *buffer)
perror("unmap fails");
exit(-1);
}
- qemu_free(entry->valid_mapping);
- qemu_free(entry);
+ g_free(entry->valid_mapping);
+ g_free(entry);
}
void xen_invalidate_map_cache(void)
@@ -357,7 +357,7 @@ void xen_invalidate_map_cache(void)
entry->paddr_index = 0;
entry->vaddr_base = NULL;
entry->size = 0;
- qemu_free(entry->valid_mapping);
+ g_free(entry->valid_mapping);
entry->valid_mapping = NULL;
}