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>
diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index 4d72014..cb45b49 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -136,7 +136,7 @@
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 @@
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 @@
while (i--) {
qemu_set_fd_handler (pfds[i].fd, NULL, NULL, NULL);
}
- qemu_free (pfds);
+ g_free (pfds);
return -1;
}
}
@@ -816,7 +816,7 @@
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 @@
alsa_anal_close (&alsa->handle, &alsa->pollhlp);
if (alsa->pcm_buf) {
- qemu_free (alsa->pcm_buf);
+ g_free (alsa->pcm_buf);
alsa->pcm_buf = NULL;
}
}
diff --git a/audio/audio.c b/audio/audio.c
index 50d2b64..5649075 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -196,7 +196,7 @@
return NULL;
}
- return qemu_mallocz (len);
+ return g_malloc0 (len);
}
static char *audio_alloc_prefix (const char *s)
@@ -210,7 +210,7 @@
}
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 @@
printf (" %s\n", opt->descr);
}
- qemu_free (uprefix);
+ g_free (uprefix);
}
static void audio_process_options (const char *prefix,
@@ -462,7 +462,7 @@
* (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 @@
opt->overriddenp = &opt->overridden;
}
*opt->overriddenp = !def;
- qemu_free (optname);
+ g_free (optname);
}
}
@@ -778,7 +778,7 @@
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 @@
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 @@
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_remove_card (QEMUSoundCard *card)
{
QLIST_REMOVE (card, entries);
- qemu_free (card->name);
+ g_free (card->name);
}
@@ -2000,11 +2000,11 @@
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 @@
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 @@
}
QLIST_REMOVE (sw, entries);
QLIST_REMOVE (sc, entries);
- qemu_free (sc);
+ g_free (sc);
sw = sw1;
}
QLIST_REMOVE (cap, entries);
- qemu_free (cap);
+ g_free (cap);
}
return;
}
diff --git a/audio/audio_template.h b/audio/audio_template.h
index fd4469e..e62a713 100644
--- a/audio/audio_template.h
+++ b/audio/audio_template.h
@@ -72,7 +72,7 @@
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 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 @@
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 @@
[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 @@
{
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 @@
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 @@
err1:
glue (hw->pcm_ops->fini_, TYPE) (hw);
err0:
- qemu_free (hw);
+ g_free (hw);
return NULL;
}
@@ -368,7 +368,7 @@
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 @@
glue (audio_pcm_sw_fini_, TYPE) (sw);
glue (audio_pcm_hw_del_sw_, TYPE) (sw);
glue (audio_pcm_hw_gc_, TYPE) (&sw->hw);
- qemu_free (sw);
+ g_free (sw);
}
void glue (AUD_close_, TYPE) (QEMUSoundCard *card, SW *sw)
diff --git a/audio/esdaudio.c b/audio/esdaudio.c
index ff97b39..bd6e1cc 100644
--- a/audio/esdaudio.c
+++ b/audio/esdaudio.c
@@ -246,7 +246,7 @@
esd->fd = -1;
fail1:
- qemu_free (esd->pcm_buf);
+ g_free (esd->pcm_buf);
esd->pcm_buf = NULL;
return -1;
}
@@ -270,7 +270,7 @@
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 @@
esd->fd = -1;
fail1:
- qemu_free (esd->pcm_buf);
+ g_free (esd->pcm_buf);
esd->pcm_buf = NULL;
return -1;
}
@@ -477,7 +477,7 @@
audio_pt_fini (&esd->pt, AUDIO_FUNC);
- qemu_free (esd->pcm_buf);
+ g_free (esd->pcm_buf);
esd->pcm_buf = NULL;
}
diff --git a/audio/mixeng.c b/audio/mixeng.c
index 4a9e8eb..5446be6 100644
--- a/audio/mixeng.c
+++ b/audio/mixeng.c
@@ -326,7 +326,7 @@
void st_rate_stop (void *opaque)
{
- qemu_free (opaque);
+ g_free (opaque);
}
void mixeng_clear (struct st_sample *buf, int len)
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index b49e102..df51b7c 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -508,7 +508,7 @@
}
}
else {
- qemu_free (oss->pcm_buf);
+ g_free (oss->pcm_buf);
}
oss->pcm_buf = NULL;
}
@@ -741,7 +741,7 @@
oss_anal_close (&oss->fd);
if (oss->pcm_buf) {
- qemu_free (oss->pcm_buf);
+ g_free (oss->pcm_buf);
oss->pcm_buf = NULL;
}
}
diff --git a/audio/paaudio.c b/audio/paaudio.c
index fb4510e..d1f3912 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -339,7 +339,7 @@
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 @@
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 @@
}
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 @@
}
audio_pt_fini (&pa->pt, AUDIO_FUNC);
- qemu_free (pa->pcm_buf);
+ g_free (pa->pcm_buf);
pa->pcm_buf = NULL;
}
diff --git a/audio/wavaudio.c b/audio/wavaudio.c
index 294f357..aed1817 100644
--- a/audio/wavaudio.c
+++ b/audio/wavaudio.c
@@ -156,7 +156,7 @@
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 @@
qemu_fclose (wav->f);
wav->f = NULL;
- qemu_free (wav->pcm_buf);
+ g_free (wav->pcm_buf);
wav->pcm_buf = NULL;
}
diff --git a/audio/wavcapture.c b/audio/wavcapture.c
index 1f49cd1..c64f0ef 100644
--- a/audio/wavcapture.c
+++ b/audio/wavcapture.c
@@ -48,7 +48,7 @@
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 @@
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 @@
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 @@
cap = AUD_add_capture (&as, &ops, wav);
if (!cap) {
monitor_printf(mon, "Failed to add audio capture\n");
- qemu_free (wav->path);
+ g_free (wav->path);
qemu_fclose (wav->f);
- qemu_free (wav);
+ g_free (wav);
return -1;
}
diff --git a/audio/winwaveaudio.c b/audio/winwaveaudio.c
index e5ad3c6..87e7493 100644
--- a/audio/winwaveaudio.c
+++ b/audio/winwaveaudio.c
@@ -222,9 +222,9 @@
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 @@
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 @@
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 @@
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;
}