Use glib memory allocation and free functions

qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Anthony Liguori 2011-08-20 22:09:37 -05:00
parent 14015304b6
commit 7267c0947d
357 changed files with 1672 additions and 1674 deletions

14
acl.c
View File

@ -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) {

6
aio.c
View File

@ -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);
}
}

View File

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

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

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

View File

@ -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;
}

View File

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

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

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

View File

@ -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;
}

34
block.c
View File

@ -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;
}
}

View File

@ -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);
}
}
}

View File

@ -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 = {

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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 = {

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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) {

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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));
}

View File

@ -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,

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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");

View File

@ -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);
}

View File

@ -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_,

View File

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

8
cpus.c
View File

@ -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) {

View File

@ -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]));
}

View File

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

View File

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

View File

@ -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;
}

View File

@ -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 {

10
error.c
View File

@ -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);

48
exec.c
View File

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

View File

@ -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);

View File

@ -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 {

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

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

View File

@ -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");

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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]);

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

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

View File

@ -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;

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

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

View File

@ -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;
}

View File

@ -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);

View File

@ -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 = {

View File

@ -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);
}

View File

@ -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);

View File

@ -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];

View File

@ -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;

Some files were not shown because too many files have changed in this diff Show More