Skip to content

Commit

Permalink
Use glib memory allocation and free functions
Browse files Browse the repository at this point in the history
qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <[email protected]>
  • Loading branch information
Anthony Liguori committed Aug 21, 2011
1 parent 1401530 commit 7267c09
Show file tree
Hide file tree
Showing 357 changed files with 1,672 additions and 1,674 deletions.
14 changes: 7 additions & 7 deletions acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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++;

Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -220,7 +220,7 @@ void qemu_aio_wait(void)

if (tmp->deleted) {
QLIST_REMOVE(tmp, node);
qemu_free(tmp);
g_free(tmp);
}
}

Expand Down
4 changes: 2 additions & 2 deletions arch_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions async.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions audio/alsaaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
30 changes: 15 additions & 15 deletions audio/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1907,15 +1907,15 @@ 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);
}

void AUD_remove_card (QEMUSoundCard *card)
{
QLIST_REMOVE (card, entries);
qemu_free (card->name);
g_free (card->name);
}


Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
20 changes: 10 additions & 10 deletions audio/audio_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -368,7 +368,7 @@ static SW *glue (audio_pcm_create_voice_pair_, TYPE) (
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;
}
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions audio/esdaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion audio/mixeng.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 7267c09

Please sign in to comment.