Commit 7267c094 authored by Anthony Liguori's avatar Anthony Liguori
Browse files

Use glib memory allocation and free functions



qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent 14015304
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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) {
+3 −3
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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)
+2 −2
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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;
    }
}
Loading