From 7267c0947d7e8ae5dff7bafd932c3bc285f43e5c Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Sat, 20 Aug 2011 22:09:37 -0500 Subject: Use glib memory allocation and free functions qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori --- block.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'block.c') diff --git a/block.c b/block.c index 26910ca143..785c88e171 100644 --- a/block.c +++ b/block.c @@ -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; } } -- cgit v1.2.3