mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
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:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+5
-5
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+15
-15
@@ -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;
|
||||
}
|
||||
|
||||
+10
-10
@@ -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)
|
||||
|
||||
+4
-4
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
+20
-20
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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 = {
|
||||
|
||||
+3
-3
@@ -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;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user