diff options
Diffstat (limited to 'block')
-rw-r--r-- | block/blkdebug.c | 4 | ||||
-rw-r--r-- | block/bochs.c | 4 | ||||
-rw-r--r-- | block/cloop.c | 6 | ||||
-rw-r--r-- | block/curl.c | 10 | ||||
-rw-r--r-- | block/dmg.c | 14 | ||||
-rw-r--r-- | block/nbd.c | 18 | ||||
-rw-r--r-- | block/parallels.c | 6 | ||||
-rw-r--r-- | block/qcow.c | 36 | ||||
-rw-r--r-- | block/qcow2-cache.c | 8 | ||||
-rw-r--r-- | block/qcow2-cluster.c | 12 | ||||
-rw-r--r-- | block/qcow2-refcount.c | 34 | ||||
-rw-r--r-- | block/qcow2-snapshot.c | 38 | ||||
-rw-r--r-- | block/qcow2.c | 36 | ||||
-rw-r--r-- | block/qed-check.c | 4 | ||||
-rw-r--r-- | block/qed-cluster.c | 4 | ||||
-rw-r--r-- | block/qed-gencb.c | 4 | ||||
-rw-r--r-- | block/qed-l2-cache.c | 6 | ||||
-rw-r--r-- | block/qed.c | 8 | ||||
-rw-r--r-- | block/raw.c | 2 | ||||
-rw-r--r-- | block/rbd.c | 26 | ||||
-rw-r--r-- | block/sheepdog.c | 52 | ||||
-rw-r--r-- | block/vdi.c | 16 | ||||
-rw-r--r-- | block/vmdk.c | 22 | ||||
-rw-r--r-- | block/vpc.c | 8 | ||||
-rw-r--r-- | block/vvfat.c | 32 |
25 files changed, 205 insertions, 205 deletions
diff --git a/block/blkdebug.c b/block/blkdebug.c index cd9eb8006a..b3c5d42cef 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -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); } } } diff --git a/block/bochs.c b/block/bochs.c index 5fe2fa3580..3c2f8d1b12 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -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 = { diff --git a/block/cloop.c b/block/cloop.c index fe015c4255..8cff9f2cac 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -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; diff --git a/block/curl.c b/block/curl.c index 407f0955a3..5c157bc609 100644 --- a/block/curl.c +++ b/block/curl.c @@ -310,7 +310,7 @@ static int curl_open(BlockDriverState *bs, const char *filename, int flags) static int inited = 0; - file = qemu_strdup(filename); + file = g_strdup(filename); s->readahead_size = READ_AHEAD_SIZE; /* Parse a trailing ":readahead=#:" param, if present. */ @@ -390,7 +390,7 @@ out: curl_easy_cleanup(state->curl); state->curl = NULL; out_noclean: - qemu_free(file); + g_free(file); return -EINVAL; } @@ -444,11 +444,11 @@ static BlockDriverAIOCB *curl_aio_readv(BlockDriverState *bs, state->buf_off = 0; if (state->orig_buf) - qemu_free(state->orig_buf); + g_free(state->orig_buf); state->buf_start = start; state->buf_len = acb->end + s->readahead_size; end = MIN(start + state->buf_len, s->len) - 1; - state->orig_buf = qemu_malloc(state->buf_len); + state->orig_buf = g_malloc(state->buf_len); state->acb[0] = acb; snprintf(state->range, 127, "%zd-%zd", start, end); @@ -476,7 +476,7 @@ static void curl_close(BlockDriverState *bs) s->states[i].curl = NULL; } if (s->states[i].orig_buf) { - qemu_free(s->states[i].orig_buf); + g_free(s->states[i].orig_buf); s->states[i].orig_buf = NULL; } } diff --git a/block/dmg.c b/block/dmg.c index a3c815b862..64c3cce46a 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -127,11 +127,11 @@ static int dmg_open(BlockDriverState *bs, int flags) chunk_count = (count-204)/40; new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count); - s->types = qemu_realloc(s->types, new_size/2); - s->offsets = qemu_realloc(s->offsets, new_size); - s->lengths = qemu_realloc(s->lengths, new_size); - s->sectors = qemu_realloc(s->sectors, new_size); - s->sectorcounts = qemu_realloc(s->sectorcounts, new_size); + s->types = g_realloc(s->types, new_size/2); + s->offsets = g_realloc(s->offsets, new_size); + s->lengths = g_realloc(s->lengths, new_size); + s->sectors = g_realloc(s->sectors, new_size); + s->sectorcounts = g_realloc(s->sectorcounts, new_size); for(i=s->n_chunks;i<s->n_chunks+chunk_count;i++) { s->types[i] = read_uint32(bs, offset); @@ -170,8 +170,8 @@ static int dmg_open(BlockDriverState *bs, int flags) } /* initialize zlib engine */ - s->compressed_chunk = qemu_malloc(max_compressed_size+1); - s->uncompressed_chunk = qemu_malloc(512*max_sectors_per_chunk); + s->compressed_chunk = g_malloc(max_compressed_size+1); + s->uncompressed_chunk = g_malloc(512*max_sectors_per_chunk); if(inflateInit(&s->zstream) != Z_OK) goto fail; diff --git a/block/nbd.c b/block/nbd.c index 7a52f62e7e..55cb2fd8ba 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -65,7 +65,7 @@ static int nbd_config(BDRVNBDState *s, const char *filename, int flags) const char *unixpath; int err = -EINVAL; - file = qemu_strdup(filename); + file = g_strdup(filename); export_name = strstr(file, EN_OPTSTR); if (export_name) { @@ -74,7 +74,7 @@ static int nbd_config(BDRVNBDState *s, const char *filename, int flags) } export_name[0] = 0; /* truncate 'file' */ export_name += strlen(EN_OPTSTR); - s->export_name = qemu_strdup(export_name); + s->export_name = g_strdup(export_name); } /* extract the host_spec - fail if it's not nbd:... */ @@ -87,18 +87,18 @@ static int nbd_config(BDRVNBDState *s, const char *filename, int flags) if (unixpath[0] != '/') { /* We demand an absolute path*/ goto out; } - s->host_spec = qemu_strdup(unixpath); + s->host_spec = g_strdup(unixpath); } else { - s->host_spec = qemu_strdup(host_spec); + s->host_spec = g_strdup(host_spec); } err = 0; out: - qemu_free(file); + g_free(file); if (err != 0) { - qemu_free(s->export_name); - qemu_free(s->host_spec); + g_free(s->export_name); + g_free(s->host_spec); } return err; } @@ -240,8 +240,8 @@ static int nbd_write(BlockDriverState *bs, int64_t sector_num, static void nbd_close(BlockDriverState *bs) { BDRVNBDState *s = bs->opaque; - qemu_free(s->export_name); - qemu_free(s->host_spec); + g_free(s->export_name); + g_free(s->host_spec); nbd_teardown_connection(bs); } diff --git a/block/parallels.c b/block/parallels.c index 35a14aa422..37d151dcb5 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -88,7 +88,7 @@ static int parallels_open(BlockDriverState *bs, int flags) s->tracks = le32_to_cpu(ph.tracks); s->catalog_size = le32_to_cpu(ph.catalog_entries); - s->catalog_bitmap = qemu_malloc(s->catalog_size * 4); + s->catalog_bitmap = g_malloc(s->catalog_size * 4); if (bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4) != s->catalog_size * 4) goto fail; @@ -98,7 +98,7 @@ static int parallels_open(BlockDriverState *bs, int flags) return 0; fail: if (s->catalog_bitmap) - qemu_free(s->catalog_bitmap); + g_free(s->catalog_bitmap); return -1; } @@ -137,7 +137,7 @@ static int parallels_read(BlockDriverState *bs, int64_t sector_num, static void parallels_close(BlockDriverState *bs) { BDRVParallelsState *s = bs->opaque; - qemu_free(s->catalog_bitmap); + g_free(s->catalog_bitmap); } static BlockDriver bdrv_parallels = { diff --git a/block/qcow.c b/block/qcow.c index 6447c2a1c0..e155d3c002 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -129,7 +129,7 @@ static int qcow_open(BlockDriverState *bs, int flags) s->l1_size = (header.size + (1LL << shift) - 1) >> shift; s->l1_table_offset = header.l1_table_offset; - s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t)); + s->l1_table = g_malloc(s->l1_size * sizeof(uint64_t)); if (!s->l1_table) goto fail; if (bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)) != @@ -139,13 +139,13 @@ static int qcow_open(BlockDriverState *bs, int flags) be64_to_cpus(&s->l1_table[i]); } /* alloc L2 cache */ - s->l2_cache = qemu_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t)); + s->l2_cache = g_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t)); if (!s->l2_cache) goto fail; - s->cluster_cache = qemu_malloc(s->cluster_size); + s->cluster_cache = g_malloc(s->cluster_size); if (!s->cluster_cache) goto fail; - s->cluster_data = qemu_malloc(s->cluster_size); + s->cluster_data = g_malloc(s->cluster_size); if (!s->cluster_data) goto fail; s->cluster_cache_offset = -1; @@ -162,10 +162,10 @@ static int qcow_open(BlockDriverState *bs, int flags) return 0; fail: - qemu_free(s->l1_table); - qemu_free(s->l2_cache); - qemu_free(s->cluster_cache); - qemu_free(s->cluster_data); + g_free(s->l1_table); + g_free(s->l2_cache); + g_free(s->cluster_cache); + g_free(s->cluster_data); return -1; } @@ -687,7 +687,7 @@ static int qcow_aio_write_cb(void *opaque) } if (s->crypt_method) { if (!acb->cluster_data) { - acb->cluster_data = qemu_mallocz(s->cluster_size); + acb->cluster_data = g_malloc0(s->cluster_size); } encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf, acb->n, 1, &s->aes_encrypt_key); @@ -738,10 +738,10 @@ static int qcow_co_writev(BlockDriverState *bs, int64_t sector_num, static void qcow_close(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; - qemu_free(s->l1_table); - qemu_free(s->l2_cache); - qemu_free(s->cluster_cache); - qemu_free(s->cluster_data); + g_free(s->l1_table); + g_free(s->l2_cache); + g_free(s->cluster_cache); + g_free(s->cluster_data); } static int qcow_create(const char *filename, QEMUOptionParameter *options) @@ -869,7 +869,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, if (nb_sectors != s->cluster_sectors) return -EINVAL; - out_buf = qemu_malloc(s->cluster_size + (s->cluster_size / 1000) + 128); + out_buf = g_malloc(s->cluster_size + (s->cluster_size / 1000) + 128); if (!out_buf) return -1; @@ -879,7 +879,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, Z_DEFLATED, -12, 9, Z_DEFAULT_STRATEGY); if (ret != 0) { - qemu_free(out_buf); + g_free(out_buf); return -1; } @@ -890,7 +890,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, ret = deflate(&strm, Z_FINISH); if (ret != Z_STREAM_END && ret != Z_OK) { - qemu_free(out_buf); + g_free(out_buf); deflateEnd(&strm); return -1; } @@ -906,12 +906,12 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, out_len, 0, 0); cluster_offset &= s->cluster_offset_mask; if (bdrv_pwrite(bs->file, cluster_offset, out_buf, out_len) != out_len) { - qemu_free(out_buf); + g_free(out_buf); return -1; } } - qemu_free(out_buf); + g_free(out_buf); return 0; } diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 84088477a4..340a6f2b26 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -49,9 +49,9 @@ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables, Qcow2Cache *c; int i; - c = qemu_mallocz(sizeof(*c)); + c = g_malloc0(sizeof(*c)); c->size = num_tables; - c->entries = qemu_mallocz(sizeof(*c->entries) * num_tables); + c->entries = g_malloc0(sizeof(*c->entries) * num_tables); c->writethrough = writethrough; for (i = 0; i < c->size; i++) { @@ -70,8 +70,8 @@ int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c) qemu_vfree(c->entries[i].table); } - qemu_free(c->entries); - qemu_free(c); + g_free(c->entries); + g_free(c); return 0; } diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 81cf77d83c..9269ddaefd 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -57,14 +57,14 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size, bool exact_size) #endif new_l1_size2 = sizeof(uint64_t) * new_l1_size; - new_l1_table = qemu_mallocz(align_offset(new_l1_size2, 512)); + new_l1_table = g_malloc0(align_offset(new_l1_size2, 512)); memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t)); /* write new table (align to cluster) */ BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ALLOC_TABLE); new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2); if (new_l1_table_offset < 0) { - qemu_free(new_l1_table); + g_free(new_l1_table); return new_l1_table_offset; } @@ -90,14 +90,14 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size, bool exact_size) if (ret < 0) { goto fail; } - qemu_free(s->l1_table); + g_free(s->l1_table); qcow2_free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t)); s->l1_table_offset = new_l1_table_offset; s->l1_table = new_l1_table; s->l1_size = new_l1_size; return 0; fail: - qemu_free(new_l1_table); + g_free(new_l1_table); qcow2_free_clusters(bs, new_l1_table_offset, new_l1_size2); return ret; } @@ -612,7 +612,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m) if (m->nb_clusters == 0) return 0; - old_cluster = qemu_malloc(m->nb_clusters * sizeof(uint64_t)); + old_cluster = g_malloc(m->nb_clusters * sizeof(uint64_t)); /* copy content of unmodified sectors */ start_sect = (m->offset & ~(s->cluster_size - 1)) >> 9; @@ -683,7 +683,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m) ret = 0; err: - qemu_free(old_cluster); + g_free(old_cluster); return ret; } diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 14b2f67f14..2a915be57a 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -41,7 +41,7 @@ int qcow2_refcount_init(BlockDriverState *bs) int ret, refcount_table_size2, i; refcount_table_size2 = s->refcount_table_size * sizeof(uint64_t); - s->refcount_table = qemu_malloc(refcount_table_size2); + s->refcount_table = g_malloc(refcount_table_size2); if (s->refcount_table_size > 0) { BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD); ret = bdrv_pread(bs->file, s->refcount_table_offset, @@ -59,7 +59,7 @@ int qcow2_refcount_init(BlockDriverState *bs) void qcow2_refcount_close(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; - qemu_free(s->refcount_table); + g_free(s->refcount_table); } @@ -323,8 +323,8 @@ static int alloc_refcount_block(BlockDriverState *bs, uint64_t meta_offset = (blocks_used * refcount_block_clusters) * s->cluster_size; uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size; - uint16_t *new_blocks = qemu_mallocz(blocks_clusters * s->cluster_size); - uint64_t *new_table = qemu_mallocz(table_size * sizeof(uint64_t)); + uint16_t *new_blocks = g_malloc0(blocks_clusters * s->cluster_size); + uint64_t *new_table = g_malloc0(table_size * sizeof(uint64_t)); assert(meta_offset >= (s->free_cluster_index * s->cluster_size)); @@ -349,7 +349,7 @@ static int alloc_refcount_block(BlockDriverState *bs, BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS); ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks, blocks_clusters * s->cluster_size); - qemu_free(new_blocks); + g_free(new_blocks); if (ret < 0) { goto fail_table; } @@ -385,7 +385,7 @@ static int alloc_refcount_block(BlockDriverState *bs, uint64_t old_table_offset = s->refcount_table_offset; uint64_t old_table_size = s->refcount_table_size; - qemu_free(s->refcount_table); + g_free(s->refcount_table); s->refcount_table = new_table; s->refcount_table_size = table_size; s->refcount_table_offset = table_offset; @@ -403,7 +403,7 @@ static int alloc_refcount_block(BlockDriverState *bs, return new_block; fail_table: - qemu_free(new_table); + g_free(new_table); fail_block: if (*refcount_block != NULL) { qcow2_cache_put(bs, s->refcount_block_cache, (void**) refcount_block); @@ -720,7 +720,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs, l1_size2 = l1_size * sizeof(uint64_t); if (l1_table_offset != s->l1_table_offset) { if (l1_size2 != 0) { - l1_table = qemu_mallocz(align_offset(l1_size2, 512)); + l1_table = g_malloc0(align_offset(l1_size2, 512)); } else { l1_table = NULL; } @@ -847,7 +847,7 @@ fail: be64_to_cpus(&l1_table[i]); } if (l1_allocated) - qemu_free(l1_table); + g_free(l1_table); return ret; } @@ -921,7 +921,7 @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, /* Read L2 table from disk */ l2_size = s->l2_size * sizeof(uint64_t); - l2_table = qemu_malloc(l2_size); + l2_table = g_malloc(l2_size); if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size) goto fail; @@ -979,12 +979,12 @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, } } - qemu_free(l2_table); + g_free(l2_table); return 0; fail: fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n"); - qemu_free(l2_table); + g_free(l2_table); return -EIO; } @@ -1017,7 +1017,7 @@ static int check_refcounts_l1(BlockDriverState *bs, if (l1_size2 == 0) { l1_table = NULL; } else { - l1_table = qemu_malloc(l1_size2); + l1_table = g_malloc(l1_size2); if (bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2) != l1_size2) goto fail; @@ -1065,13 +1065,13 @@ static int check_refcounts_l1(BlockDriverState *bs, } } } - qemu_free(l1_table); + g_free(l1_table); return 0; fail: fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n"); res->check_errors++; - qemu_free(l1_table); + g_free(l1_table); return -EIO; } @@ -1092,7 +1092,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res) size = bdrv_getlength(bs->file); nb_clusters = size_to_clusters(s, size); - refcount_table = qemu_mallocz(nb_clusters * sizeof(uint16_t)); + refcount_table = g_malloc0(nb_clusters * sizeof(uint16_t)); /* header */ inc_refcounts(bs, res, refcount_table, nb_clusters, @@ -1178,7 +1178,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res) ret = 0; fail: - qemu_free(refcount_table); + g_free(refcount_table); return ret; } diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index e32bcf084c..3bd2a30d35 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -52,10 +52,10 @@ void qcow2_free_snapshots(BlockDriverState *bs) int i; for(i = 0; i < s->nb_snapshots; i++) { - qemu_free(s->snapshots[i].name); - qemu_free(s->snapshots[i].id_str); + g_free(s->snapshots[i].name); + g_free(s->snapshots[i].id_str); } - qemu_free(s->snapshots); + g_free(s->snapshots); s->snapshots = NULL; s->nb_snapshots = 0; } @@ -76,7 +76,7 @@ int qcow2_read_snapshots(BlockDriverState *bs) } offset = s->snapshots_offset; - s->snapshots = qemu_mallocz(s->nb_snapshots * sizeof(QCowSnapshot)); + s->snapshots = g_malloc0(s->nb_snapshots * sizeof(QCowSnapshot)); for(i = 0; i < s->nb_snapshots; i++) { offset = align_offset(offset, 8); if (bdrv_pread(bs->file, offset, &h, sizeof(h)) != sizeof(h)) @@ -96,13 +96,13 @@ int qcow2_read_snapshots(BlockDriverState *bs) offset += extra_data_size; - sn->id_str = qemu_malloc(id_str_size + 1); + sn->id_str = g_malloc(id_str_size + 1); if (bdrv_pread(bs->file, offset, sn->id_str, id_str_size) != id_str_size) goto fail; offset += id_str_size; sn->id_str[id_str_size] = '\0'; - sn->name = qemu_malloc(name_size + 1); + sn->name = g_malloc(name_size + 1); if (bdrv_pread(bs->file, offset, sn->name, name_size) != name_size) goto fail; offset += name_size; @@ -252,10 +252,10 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) if (find_snapshot_by_id(bs, sn_info->id_str) >= 0) return -ENOENT; - sn->id_str = qemu_strdup(sn_info->id_str); + sn->id_str = g_strdup(sn_info->id_str); if (!sn->id_str) goto fail; - sn->name = qemu_strdup(sn_info->name); + sn->name = g_strdup(sn_info->name); if (!sn->name) goto fail; sn->vm_state_size = sn_info->vm_state_size; @@ -278,7 +278,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) sn->l1_size = s->l1_size; if (s->l1_size != 0) { - l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t)); + l1_table = g_malloc(s->l1_size * sizeof(uint64_t)); } else { l1_table = NULL; } @@ -289,13 +289,13 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) if (bdrv_pwrite_sync(bs->file, sn->l1_table_offset, l1_table, s->l1_size * sizeof(uint64_t)) < 0) goto fail; - qemu_free(l1_table); + g_free(l1_table); l1_table = NULL; - snapshots1 = qemu_malloc((s->nb_snapshots + 1) * sizeof(QCowSnapshot)); + snapshots1 = g_malloc((s->nb_snapshots + 1) * sizeof(QCowSnapshot)); if (s->snapshots) { memcpy(snapshots1, s->snapshots, s->nb_snapshots * sizeof(QCowSnapshot)); - qemu_free(s->snapshots); + g_free(s->snapshots); } s->snapshots = snapshots1; s->snapshots[s->nb_snapshots++] = *sn; @@ -307,8 +307,8 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) #endif return 0; fail: - qemu_free(sn->name); - qemu_free(l1_table); + g_free(sn->name); + g_free(l1_table); return -1; } @@ -380,8 +380,8 @@ int qcow2_snapshot_delete(BlockDriverState *bs, const char *snapshot_id) return ret; qcow2_free_clusters(bs, sn->l1_table_offset, sn->l1_size * sizeof(uint64_t)); - qemu_free(sn->id_str); - qemu_free(sn->name); + g_free(sn->id_str); + g_free(sn->name); memmove(sn, sn + 1, (s->nb_snapshots - snapshot_index - 1) * sizeof(*sn)); s->nb_snapshots--; ret = qcow2_write_snapshots(bs); @@ -407,7 +407,7 @@ int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) return s->nb_snapshots; } - sn_tab = qemu_mallocz(s->nb_snapshots * sizeof(QEMUSnapshotInfo)); + sn_tab = g_malloc0(s->nb_snapshots * sizeof(QEMUSnapshotInfo)); for(i = 0; i < s->nb_snapshots; i++) { sn_info = sn_tab + i; sn = s->snapshots + i; @@ -439,11 +439,11 @@ int qcow2_snapshot_load_tmp(BlockDriverState *bs, const char *snapshot_name) s->l1_size = sn->l1_size; l1_size2 = s->l1_size * sizeof(uint64_t); if (s->l1_table != NULL) { - qemu_free(s->l1_table); + g_free(s->l1_table); } s->l1_table_offset = sn->l1_table_offset; - s->l1_table = qemu_mallocz(align_offset(l1_size2, 512)); + s->l1_table = g_malloc0(align_offset(l1_size2, 512)); if (bdrv_pread(bs->file, sn->l1_table_offset, s->l1_table, l1_size2) != l1_size2) { diff --git a/block/qcow2.c b/block/qcow2.c index f07d550a96..bfff6cd963 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -216,7 +216,7 @@ static int qcow2_open(BlockDriverState *bs, int flags) } s->l1_table_offset = header.l1_table_offset; if (s->l1_size > 0) { - s->l1_table = qemu_mallocz( + s->l1_table = g_malloc0( align_offset(s->l1_size * sizeof(uint64_t), 512)); ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)); @@ -234,9 +234,9 @@ static int qcow2_open(BlockDriverState *bs, int flags) s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE, writethrough); - s->cluster_cache = qemu_malloc(s->cluster_size); + s->cluster_cache = g_malloc(s->cluster_size); /* one more sector for decompressed data alignment */ - s->cluster_data = qemu_malloc(QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size + s->cluster_data = g_malloc(QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size + 512); s->cluster_cache_offset = -1; @@ -287,12 +287,12 @@ static int qcow2_open(BlockDriverState *bs, int flags) fail: qcow2_free_snapshots(bs); qcow2_refcount_close(bs); - qemu_free(s->l1_table); + g_free(s->l1_table); if (s->l2_table_cache) { qcow2_cache_destroy(bs, s->l2_table_cache); } - qemu_free(s->cluster_cache); - qemu_free(s->cluster_data); + g_free(s->cluster_cache); + g_free(s->cluster_data); return ret; } @@ -501,7 +501,7 @@ static int qcow2_aio_read_cb(QCowAIOCB *acb) */ if (!acb->cluster_data) { acb->cluster_data = - qemu_mallocz(QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); + g_malloc0(QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); } assert(acb->cur_nr_sectors <= @@ -636,7 +636,7 @@ static int qcow2_aio_write_cb(QCowAIOCB *acb) if (s->crypt_method) { if (!acb->cluster_data) { - acb->cluster_data = qemu_mallocz(QCOW_MAX_CRYPT_CLUSTERS * + acb->cluster_data = g_malloc0(QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); } @@ -691,7 +691,7 @@ static int qcow2_co_writev(BlockDriverState *bs, static void qcow2_close(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; - qemu_free(s->l1_table); + g_free(s->l1_table); qcow2_cache_flush(bs, s->l2_table_cache); qcow2_cache_flush(bs, s->refcount_block_cache); @@ -699,8 +699,8 @@ static void qcow2_close(BlockDriverState *bs) qcow2_cache_destroy(bs, s->l2_table_cache); qcow2_cache_destroy(bs, s->refcount_block_cache); - qemu_free(s->cluster_cache); - qemu_free(s->cluster_data); + g_free(s->cluster_cache); + g_free(s->cluster_data); qcow2_refcount_close(bs); } @@ -923,9 +923,9 @@ static int qcow2_create2(const char *filename, int64_t total_size, } /* Write an empty refcount table */ - refcount_table = qemu_mallocz(cluster_size); + refcount_table = g_malloc0(cluster_size); ret = bdrv_pwrite(bs, cluster_size, refcount_table, cluster_size); - qemu_free(refcount_table); + g_free(refcount_table); if (ret < 0) { goto out; @@ -1117,7 +1117,7 @@ static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num, if (nb_sectors != s->cluster_sectors) return -EINVAL; - out_buf = qemu_malloc(s->cluster_size + (s->cluster_size / 1000) + 128); + out_buf = g_malloc(s->cluster_size + (s->cluster_size / 1000) + 128); /* best compression, small window, no zlib header */ memset(&strm, 0, sizeof(strm)); @@ -1125,7 +1125,7 @@ static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num, Z_DEFLATED, -12, 9, Z_DEFAULT_STRATEGY); if (ret != 0) { - qemu_free(out_buf); + g_free(out_buf); return -1; } @@ -1136,7 +1136,7 @@ static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num, ret = deflate(&strm, Z_FINISH); if (ret != Z_STREAM_END && ret != Z_OK) { - qemu_free(out_buf); + g_free(out_buf); deflateEnd(&strm); return -1; } @@ -1155,12 +1155,12 @@ static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num, cluster_offset &= s->cluster_offset_mask; BLKDBG_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED); if (bdrv_pwrite(bs->file, cluster_offset, out_buf, out_len) != out_len) { - qemu_free(out_buf); + g_free(out_buf); return -1; } } - qemu_free(out_buf); + g_free(out_buf); return 0; } diff --git a/block/qed-check.c b/block/qed-check.c index 22cd07fa1f..e4a49ce72c 100644 --- a/block/qed-check.c +++ b/block/qed-check.c @@ -197,7 +197,7 @@ int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix) }; int ret; - check.used_clusters = qemu_mallocz(((check.nclusters + 31) / 32) * + check.used_clusters = g_malloc0(((check.nclusters + 31) / 32) * sizeof(check.used_clusters[0])); ret = qed_check_l1_table(&check, s->l1_table); @@ -206,6 +206,6 @@ int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix) qed_check_for_leaks(&check); } - qemu_free(check.used_clusters); + g_free(check.used_clusters); return ret; } diff --git a/block/qed-cluster.c b/block/qed-cluster.c index 3e19ad1766..f64b2af8f7 100644 --- a/block/qed-cluster.c +++ b/block/qed-cluster.c @@ -108,7 +108,7 @@ static void qed_find_cluster_cb(void *opaque, int ret) out: find_cluster_cb->cb(find_cluster_cb->opaque, ret, offset, len); - qemu_free(find_cluster_cb); + g_free(find_cluster_cb); } /** @@ -152,7 +152,7 @@ void qed_find_cluster(BDRVQEDState *s, QEDRequest *request, uint64_t pos, return; } - find_cluster_cb = qemu_malloc(sizeof(*find_cluster_cb)); + find_cluster_cb = g_malloc(sizeof(*find_cluster_cb)); find_cluster_cb->s = s; find_cluster_cb->pos = pos; find_cluster_cb->len = len; diff --git a/block/qed-gencb.c b/block/qed-gencb.c index 1513dc6f79..7d7ac1ffc8 100644 --- a/block/qed-gencb.c +++ b/block/qed-gencb.c @@ -15,7 +15,7 @@ void *gencb_alloc(size_t len, BlockDriverCompletionFunc *cb, void *opaque) { - GenericCB *gencb = qemu_malloc(len); + GenericCB *gencb = g_malloc(len); gencb->cb = cb; gencb->opaque = opaque; return gencb; @@ -27,6 +27,6 @@ void gencb_complete(void *opaque, int ret) BlockDriverCompletionFunc *cb = gencb->cb; void *user_opaque = gencb->opaque; - qemu_free(gencb); + g_free(gencb); cb(user_opaque, ret); } diff --git a/block/qed-l2-cache.c b/block/qed-l2-cache.c index 57518a4e7f..02b81a2e33 100644 --- a/block/qed-l2-cache.c +++ b/block/qed-l2-cache.c @@ -74,7 +74,7 @@ void qed_free_l2_cache(L2TableCache *l2_cache) QTAILQ_FOREACH_SAFE(entry, &l2_cache->entries, node, next_entry) { qemu_vfree(entry->table); - qemu_free(entry); + g_free(entry); } } @@ -89,7 +89,7 @@ CachedL2Table *qed_alloc_l2_cache_entry(L2TableCache *l2_cache) { CachedL2Table *entry; - entry = qemu_mallocz(sizeof(*entry)); + entry = g_malloc0(sizeof(*entry)); entry->ref++; trace_qed_alloc_l2_cache_entry(l2_cache, entry); @@ -111,7 +111,7 @@ void qed_unref_l2_cache_entry(CachedL2Table *entry) trace_qed_unref_l2_cache_entry(entry, entry->ref); if (entry->ref == 0) { qemu_vfree(entry->table); - qemu_free(entry); + g_free(entry); } } diff --git a/block/qed.c b/block/qed.c index 333f067582..624e261b35 100644 --- a/block/qed.c +++ b/block/qed.c @@ -595,7 +595,7 @@ static int qed_create(const char *filename, uint32_t cluster_size, goto out; } - l1_table = qemu_mallocz(l1_size); + l1_table = g_malloc0(l1_size); ret = bdrv_pwrite(bs, header.l1_table_offset, l1_table, l1_size); if (ret < 0) { goto out; @@ -603,7 +603,7 @@ static int qed_create(const char *filename, uint32_t cluster_size, ret = 0; /* success */ out: - qemu_free(l1_table); + g_free(l1_table); bdrv_delete(bs); return ret; } @@ -1419,7 +1419,7 @@ static int bdrv_qed_change_backing_file(BlockDriverState *bs, } /* Prepare new header */ - buffer = qemu_malloc(buffer_len); + buffer = g_malloc(buffer_len); qed_header_cpu_to_le(&new_header, &le_header); memcpy(buffer, &le_header, sizeof(le_header)); @@ -1430,7 +1430,7 @@ static int bdrv_qed_change_backing_file(BlockDriverState *bs, /* Write new header */ ret = bdrv_pwrite_sync(bs->file, 0, buffer, buffer_len); - qemu_free(buffer); + g_free(buffer); if (ret == 0) { memcpy(&s->header, &new_header, sizeof(new_header)); } diff --git a/block/raw.c b/block/raw.c index cb6203eeca..555db4fa56 100644 --- a/block/raw.c +++ b/block/raw.c @@ -119,7 +119,7 @@ static int raw_has_zero_init(BlockDriverState *bs) static BlockDriver bdrv_raw = { .format_name = "raw", - /* It's really 0, but we need to make qemu_malloc() happy */ + /* It's really 0, but we need to make g_malloc() happy */ .instance_size = 1, .bdrv_open = raw_open, diff --git a/block/rbd.c b/block/rbd.c index d5659cdf19..ce0f6ef6ee 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -138,7 +138,7 @@ static int qemu_rbd_parsename(const char *filename, return -EINVAL; } - buf = qemu_strdup(start); + buf = g_strdup(start); p = buf; *snap = '\0'; *conf = '\0'; @@ -165,7 +165,7 @@ static int qemu_rbd_parsename(const char *filename, ret = qemu_rbd_next_tok(conf, conf_len, p, '\0', "configuration", &p); done: - qemu_free(buf); + g_free(buf); return ret; } @@ -176,7 +176,7 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf) char value[RBD_MAX_CONF_VAL_SIZE]; int ret = 0; - buf = qemu_strdup(conf); + buf = g_strdup(conf); p = buf; while (p) { @@ -214,7 +214,7 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf) } } - qemu_free(buf); + g_free(buf); return ret; } @@ -341,7 +341,7 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb) acb->bh = qemu_bh_new(rbd_aio_bh_cb, acb); qemu_bh_schedule(acb->bh); done: - qemu_free(rcb); + g_free(rcb); } /* @@ -395,7 +395,7 @@ static int qemu_rbd_open(BlockDriverState *bs, const char *filename, int flags) } s->snap = NULL; if (snap_buf[0] != '\0') { - s->snap = qemu_strdup(snap_buf); + s->snap = g_strdup(snap_buf); } r = rados_create(&s->cluster, NULL); @@ -478,7 +478,7 @@ static void qemu_rbd_close(BlockDriverState *bs) rbd_close(s->image); rados_ioctx_destroy(s->io_ctx); - qemu_free(s->snap); + g_free(s->snap); rados_shutdown(s->cluster); } @@ -544,7 +544,7 @@ static void rbd_finish_aiocb(rbd_completion_t c, RADOSCB *rcb) ret = qemu_rbd_send_pipe(rcb->s, rcb); if (ret < 0) { error_report("failed writing to acb->s->fds"); - qemu_free(rcb); + g_free(rcb); } } @@ -605,7 +605,7 @@ static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState *bs, s->qemu_aio_count++; /* All the RADOSCB */ - rcb = qemu_malloc(sizeof(RADOSCB)); + rcb = g_malloc(sizeof(RADOSCB)); rcb->done = 0; rcb->acb = acb; rcb->buf = buf; @@ -629,7 +629,7 @@ static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState *bs, return &acb->common; failed: - qemu_free(rcb); + g_free(rcb); s->qemu_aio_count--; qemu_aio_release(acb); return NULL; @@ -739,10 +739,10 @@ static int qemu_rbd_snap_list(BlockDriverState *bs, int max_snaps = RBD_MAX_SNAPS; do { - snaps = qemu_malloc(sizeof(*snaps) * max_snaps); + snaps = g_malloc(sizeof(*snaps) * max_snaps); snap_count = rbd_snap_list(s->image, snaps, &max_snaps); if (snap_count < 0) { - qemu_free(snaps); + g_free(snaps); } } while (snap_count == -ERANGE); @@ -750,7 +750,7 @@ static int qemu_rbd_snap_list(BlockDriverState *bs, return snap_count; } - sn_tab = qemu_mallocz(snap_count * sizeof(QEMUSnapshotInfo)); + sn_tab = g_malloc0(snap_count * sizeof(QEMUSnapshotInfo)); for (i = 0; i < snap_count; i++) { const char *snap_name = snaps[i].name; diff --git a/block/sheepdog.c b/block/sheepdog.c index e150ac0123..57b6e1aad7 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -368,7 +368,7 @@ static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb, { AIOReq *aio_req; - aio_req = qemu_malloc(sizeof(*aio_req)); + aio_req = g_malloc(sizeof(*aio_req)); aio_req->aiocb = acb; aio_req->iov_offset = iov_offset; aio_req->oid = oid; @@ -390,7 +390,7 @@ static inline int free_aio_req(BDRVSheepdogState *s, AIOReq *aio_req) SheepdogAIOCB *acb = aio_req->aiocb; QLIST_REMOVE(aio_req, outstanding_aio_siblings); QLIST_REMOVE(aio_req, aioreq_siblings); - qemu_free(aio_req); + g_free(aio_req); return !QLIST_EMPTY(&acb->aioreq_head); } @@ -470,7 +470,7 @@ static ssize_t sendmsg(int s, const struct msghdr *msg, int flags) for (i = 0; i < msg->msg_iovlen; i++) { size += msg->msg_iov[i].iov_len; } - buf = qemu_malloc(size); + buf = g_malloc(size); p = buf; for (i = 0; i < msg->msg_iovlen; i++) { @@ -480,7 +480,7 @@ static ssize_t sendmsg(int s, const struct msghdr *msg, int flags) ret = send(s, buf, size, flags); - qemu_free(buf); + g_free(buf); return ret; } @@ -494,7 +494,7 @@ static ssize_t recvmsg(int s, struct msghdr *msg, int flags) for (i = 0; i < msg->msg_iovlen; i++) { size += msg->msg_iov[i].iov_len; } - buf = qemu_malloc(size); + buf = g_malloc(size); ret = qemu_recv(s, buf, size, flags); if (ret < 0) { @@ -507,7 +507,7 @@ static ssize_t recvmsg(int s, struct msghdr *msg, int flags) p += msg->msg_iov[i].iov_len; } out: - qemu_free(buf); + g_free(buf); return ret; } @@ -952,7 +952,7 @@ static int parse_vdiname(BDRVSheepdogState *s, const char *filename, char *p, *q; int nr_sep; - p = q = qemu_strdup(filename); + p = q = g_strdup(filename); /* count the number of separators */ nr_sep = 0; @@ -992,7 +992,7 @@ static int parse_vdiname(BDRVSheepdogState *s, const char *filename, } if (s->addr == NULL) { - qemu_free(q); + g_free(q); } return 0; @@ -1210,7 +1210,7 @@ static int sd_open(BlockDriverState *bs, const char *filename, int flags) goto out; } - buf = qemu_malloc(SD_INODE_SIZE); + buf = g_malloc(SD_INODE_SIZE); ret = read_object(fd, buf, vid_to_vdi_oid(vid), 0, SD_INODE_SIZE, 0); closesocket(fd); @@ -1225,14 +1225,14 @@ static int sd_open(BlockDriverState *bs, const char *filename, int flags) bs->total_sectors = s->inode.vdi_size / SECTOR_SIZE; strncpy(s->name, vdi, sizeof(s->name)); - qemu_free(buf); + g_free(buf); return 0; out: qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL, NULL); if (s->fd >= 0) { closesocket(s->fd); } - qemu_free(buf); + g_free(buf); return -1; } @@ -1291,7 +1291,7 @@ static int sd_prealloc(const char *filename) BlockDriverState *bs = NULL; uint32_t idx, max_idx; int64_t vdi_size; - void *buf = qemu_mallocz(SD_DATA_OBJ_SIZE); + void *buf = g_malloc0(SD_DATA_OBJ_SIZE); int ret; ret = bdrv_file_open(&bs, filename, BDRV_O_RDWR); @@ -1324,7 +1324,7 @@ out: if (bs) { bdrv_delete(bs); } - qemu_free(buf); + g_free(buf); return ret; } @@ -1444,7 +1444,7 @@ static void sd_close(BlockDriverState *bs) qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL, NULL); closesocket(s->fd); - qemu_free(s->addr); + g_free(s->addr); } static int64_t sd_getlength(BlockDriverState *bs) @@ -1542,7 +1542,7 @@ static int sd_create_branch(BDRVSheepdogState *s) dprintf("%" PRIx32 " is snapshot.\n", s->inode.vdi_id); - buf = qemu_malloc(SD_INODE_SIZE); + buf = g_malloc(SD_INODE_SIZE); ret = do_sd_create(s->name, s->inode.vdi_size, s->inode.vdi_id, &vid, 1, s->addr, s->port); @@ -1574,7 +1574,7 @@ static int sd_create_branch(BDRVSheepdogState *s) dprintf("%" PRIx32 " was newly created.\n", s->inode.vdi_id); out: - qemu_free(buf); + g_free(buf); return ret; } @@ -1786,7 +1786,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) goto cleanup; } - inode = (SheepdogInode *)qemu_malloc(datalen); + inode = (SheepdogInode *)g_malloc(datalen); ret = read_object(fd, (char *)inode, vid_to_vdi_oid(new_vid), s->inode.nr_copies, datalen, 0); @@ -1816,7 +1816,7 @@ static int sd_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) uint32_t snapid = 0; int ret = -ENOENT, fd; - old_s = qemu_malloc(sizeof(BDRVSheepdogState)); + old_s = g_malloc(sizeof(BDRVSheepdogState)); memcpy(old_s, s, sizeof(BDRVSheepdogState)); @@ -1842,7 +1842,7 @@ static int sd_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) goto out; } - buf = qemu_malloc(SD_INODE_SIZE); + buf = g_malloc(SD_INODE_SIZE); ret = read_object(fd, buf, vid_to_vdi_oid(vid), s->inode.nr_copies, SD_INODE_SIZE, 0); @@ -1863,15 +1863,15 @@ static int sd_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) s->is_snapshot = 1; - qemu_free(buf); - qemu_free(old_s); + g_free(buf); + g_free(old_s); return 0; out: /* recover bdrv_sd_state */ memcpy(s, old_s, sizeof(BDRVSheepdogState)); - qemu_free(buf); - qemu_free(old_s); + g_free(buf); + g_free(old_s); error_report("failed to open. recover old bdrv_sd_state."); @@ -1898,7 +1898,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) uint64_t hval; uint32_t vid; - vdi_inuse = qemu_malloc(max); + vdi_inuse = g_malloc(max); fd = connect_to_sdog(s->addr, s->port); if (fd < 0) { @@ -1920,7 +1920,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) goto out; } - sn_tab = qemu_mallocz(nr * sizeof(*sn_tab)); + sn_tab = g_malloc0(nr * sizeof(*sn_tab)); /* calculate a vdi id with hash function */ hval = fnv_64a_buf(s->name, strlen(s->name), FNV1A_64_INIT); @@ -1963,7 +1963,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) out: *psn_tab = sn_tab; - qemu_free(vdi_inuse); + g_free(vdi_inuse); return found; } diff --git a/block/vdi.c b/block/vdi.c index 261cf9b98d..1d5ad2bf49 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -301,7 +301,7 @@ static int vdi_check(BlockDriverState *bs, BdrvCheckResult *res) uint32_t *bmap; logout("\n"); - bmap = qemu_malloc(s->header.blocks_in_image * sizeof(uint32_t)); + bmap = g_malloc(s->header.blocks_in_image * sizeof(uint32_t)); memset(bmap, 0xff, s->header.blocks_in_image * sizeof(uint32_t)); /* Check block map and value of blocks_allocated. */ @@ -331,7 +331,7 @@ static int vdi_check(BlockDriverState *bs, BdrvCheckResult *res) res->corruptions++; } - qemu_free(bmap); + g_free(bmap); return 0; } @@ -443,7 +443,7 @@ static int vdi_open(BlockDriverState *bs, int flags) bmap_size = header.blocks_in_image * sizeof(uint32_t); bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE; if (bmap_size > 0) { - s->bmap = qemu_malloc(bmap_size * SECTOR_SIZE); + s->bmap = g_malloc(bmap_size * SECTOR_SIZE); } if (bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size) < 0) { goto fail_free_bmap; @@ -452,7 +452,7 @@ static int vdi_open(BlockDriverState *bs, int flags) return 0; fail_free_bmap: - qemu_free(s->bmap); + g_free(s->bmap); fail: return -1; @@ -704,7 +704,7 @@ static void vdi_aio_write_cb(void *opaque, int ret) uint64_t offset; uint32_t bmap_first; uint32_t bmap_last; - qemu_free(acb->block_buffer); + g_free(acb->block_buffer); acb->block_buffer = NULL; bmap_first = acb->bmap_first; bmap_last = acb->bmap_last; @@ -760,7 +760,7 @@ static void vdi_aio_write_cb(void *opaque, int ret) (uint64_t)bmap_entry * s->block_sectors; block = acb->block_buffer; if (block == NULL) { - block = qemu_mallocz(s->block_size); + block = g_malloc0(s->block_size); acb->block_buffer = block; acb->bmap_first = block_index; assert(!acb->header_modified); @@ -906,7 +906,7 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options) bmap = NULL; if (bmap_size > 0) { - bmap = (uint32_t *)qemu_mallocz(bmap_size); + bmap = (uint32_t *)g_malloc0(bmap_size); } for (i = 0; i < blocks; i++) { if (image_type == VDI_TYPE_STATIC) { @@ -918,7 +918,7 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options) if (write(fd, bmap, bmap_size) < 0) { result = -errno; } - qemu_free(bmap); + g_free(bmap); if (image_type == VDI_TYPE_STATIC) { if (ftruncate(fd, sizeof(header) + bmap_size + blocks * block_size)) { result = -errno; diff --git a/block/vmdk.c b/block/vmdk.c index 37478d2553..8da87acef0 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -167,11 +167,11 @@ static void vmdk_free_extents(BlockDriverState *bs) BDRVVmdkState *s = bs->opaque; for (i = 0; i < s->num_extents; i++) { - qemu_free(s->extents[i].l1_table); - qemu_free(s->extents[i].l2_cache); - qemu_free(s->extents[i].l1_backup_table); + g_free(s->extents[i].l1_table); + g_free(s->extents[i].l2_cache); + g_free(s->extents[i].l1_backup_table); } - qemu_free(s->extents); + g_free(s->extents); } static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent) @@ -289,7 +289,7 @@ static VmdkExtent *vmdk_add_extent(BlockDriverState *bs, VmdkExtent *extent; BDRVVmdkState *s = bs->opaque; - s->extents = qemu_realloc(s->extents, + s->extents = g_realloc(s->extents, (s->num_extents + 1) * sizeof(VmdkExtent)); extent = &s->extents[s->num_extents]; s->num_extents++; @@ -321,7 +321,7 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent) /* read the L1 table */ l1_size = extent->l1_size * sizeof(uint32_t); - extent->l1_table = qemu_malloc(l1_size); + extent->l1_table = g_malloc(l1_size); ret = bdrv_pread(extent->file, extent->l1_table_offset, extent->l1_table, @@ -334,7 +334,7 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent) } if (extent->l1_backup_table_offset) { - extent->l1_backup_table = qemu_malloc(l1_size); + extent->l1_backup_table = g_malloc(l1_size); ret = bdrv_pread(extent->file, extent->l1_backup_table_offset, extent->l1_backup_table, @@ -348,12 +348,12 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent) } extent->l2_cache = - qemu_malloc(extent->l2_size * L2_CACHE_SIZE * sizeof(uint32_t)); + g_malloc(extent->l2_size * L2_CACHE_SIZE * sizeof(uint32_t)); return 0; fail_l1b: - qemu_free(extent->l1_backup_table); + g_free(extent->l1_backup_table); fail_l1: - qemu_free(extent->l1_table); + g_free(extent->l1_table); return ret; } @@ -564,7 +564,7 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags) /* try to open parent images, if exist */ if (vmdk_parent_open(bs)) { - qemu_free(s->extents); + g_free(s->extents); return -EINVAL; } s->parent_cid = vmdk_read_cid(bs, 1); diff --git a/block/vpc.c b/block/vpc.c index fdd5236892..cb6c570f44 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -196,7 +196,7 @@ static int vpc_open(BlockDriverState *bs, int flags) s->bitmap_size = ((s->block_size / (8 * 512)) + 511) & ~511; s->max_table_entries = be32_to_cpu(dyndisk_header->max_table_entries); - s->pagetable = qemu_malloc(s->max_table_entries * 4); + s->pagetable = g_malloc(s->max_table_entries * 4); s->bat_offset = be64_to_cpu(dyndisk_header->table_offset); if (bdrv_pread(bs->file, s->bat_offset, s->pagetable, @@ -220,7 +220,7 @@ static int vpc_open(BlockDriverState *bs, int flags) s->last_bitmap_offset = (int64_t) -1; #ifdef CACHE - s->pageentry_u8 = qemu_malloc(512); + s->pageentry_u8 = g_malloc(512); s->pageentry_u32 = s->pageentry_u8; s->pageentry_u16 = s->pageentry_u8; s->last_pagetable = -1; @@ -619,9 +619,9 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options) static void vpc_close(BlockDriverState *bs) { BDRVVPCState *s = bs->opaque; - qemu_free(s->pagetable); + g_free(s->pagetable); #ifdef CACHE - qemu_free(s->pageentry_u8); + g_free(s->pageentry_u8); #endif } diff --git a/block/vvfat.c b/block/vvfat.c index fe568fe2c7..d6a07efcc9 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -101,7 +101,7 @@ static inline int array_ensure_allocated(array_t* array, int index) { if((index + 1) * array->item_size > array->size) { int new_size = (index + 32) * array->item_size; - array->pointer = qemu_realloc(array->pointer, new_size); + array->pointer = g_realloc(array->pointer, new_size); if (!array->pointer) return -1; array->size = new_size; @@ -127,7 +127,7 @@ static inline void* array_get_next(array_t* array) { static inline void* array_insert(array_t* array,unsigned int index,unsigned int count) { if((array->next+count)*array->item_size>array->size) { int increment=count*array->item_size; - array->pointer=qemu_realloc(array->pointer,array->size+increment); + array->pointer=g_realloc(array->pointer,array->size+increment); if(!array->pointer) return NULL; array->size+=increment; @@ -159,7 +159,7 @@ static inline int array_roll(array_t* array,int index_to,int index_from,int coun is=array->item_size; from=array->pointer+index_from*is; to=array->pointer+index_to*is; - buf=qemu_malloc(is*count); + buf=g_malloc(is*count); memcpy(buf,from,is*count); if(index_to<index_from) @@ -728,7 +728,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index) if(first_cluster == 0 && (is_dotdot || is_dot)) continue; - buffer=(char*)qemu_malloc(length); + buffer=(char*)g_malloc(length); snprintf(buffer,length,"%s/%s",dirname,entry->d_name); if(stat(buffer,&st)<0) { @@ -850,7 +850,7 @@ static int init_directories(BDRVVVFATState* s, memset(&(s->first_sectors[0]),0,0x40*0x200); s->cluster_size=s->sectors_per_cluster*0x200; - s->cluster_buffer=qemu_malloc(s->cluster_size); + s->cluster_buffer=g_malloc(s->cluster_size); /* * The formula: sc = spf+1+spf*spc*(512*8/fat_type), @@ -884,7 +884,7 @@ static int init_directories(BDRVVVFATState* s, mapping->dir_index = 0; mapping->info.dir.parent_mapping_index = -1; mapping->first_mapping_index = -1; - mapping->path = qemu_strdup(dirname); + mapping->path = g_strdup(dirname); i = strlen(mapping->path); if (i > 0 && mapping->path[i - 1] == '/') mapping->path[i - 1] = '\0'; @@ -1638,10 +1638,10 @@ static uint32_t get_cluster_count_for_direntry(BDRVVVFATState* s, /* rename */ if (strcmp(basename, basename2)) - schedule_rename(s, cluster_num, qemu_strdup(path)); + schedule_rename(s, cluster_num, g_strdup(path)); } else if (is_file(direntry)) /* new file */ - schedule_new_file(s, qemu_strdup(path), cluster_num); + schedule_new_file(s, g_strdup(path), cluster_num); else { abort(); return 0; @@ -1735,7 +1735,7 @@ static int check_directory_consistency(BDRVVVFATState *s, int cluster_num, const char* path) { int ret = 0; - unsigned char* cluster = qemu_malloc(s->cluster_size); + unsigned char* cluster = g_malloc(s->cluster_size); direntry_t* direntries = (direntry_t*)cluster; mapping_t* mapping = find_mapping_for_cluster(s, cluster_num); @@ -1758,10 +1758,10 @@ static int check_directory_consistency(BDRVVVFATState *s, mapping->mode &= ~MODE_DELETED; if (strcmp(basename, basename2)) - schedule_rename(s, cluster_num, qemu_strdup(path)); + schedule_rename(s, cluster_num, g_strdup(path)); } else /* new directory */ - schedule_mkdir(s, cluster_num, qemu_strdup(path)); + schedule_mkdir(s, cluster_num, g_strdup(path)); lfn_init(&lfn); do { @@ -1876,7 +1876,7 @@ DLOG(checkpoint()); */ if (s->fat2 == NULL) { int size = 0x200 * s->sectors_per_fat; - s->fat2 = qemu_malloc(size); + s->fat2 = g_malloc(size); memcpy(s->fat2, s->fat.pointer, size); } check = vvfat_read(s->bs, @@ -2218,7 +2218,7 @@ static int commit_one_file(BDRVVVFATState* s, uint32_t first_cluster = c; mapping_t* mapping = find_mapping_for_cluster(s, c); uint32_t size = filesize_of_direntry(direntry); - char* cluster = qemu_malloc(s->cluster_size); + char* cluster = g_malloc(s->cluster_size); uint32_t i; int fd = 0; @@ -2383,7 +2383,7 @@ static int handle_renames_and_mkdirs(BDRVVVFATState* s) mapping_t* m = find_mapping_for_cluster(s, begin_of_direntry(d)); int l = strlen(m->path); - char* new_path = qemu_malloc(l + diff + 1); + char* new_path = g_malloc(l + diff + 1); assert(!strncmp(m->path, mapping->path, l2)); @@ -2794,7 +2794,7 @@ static int enable_write_target(BDRVVVFATState *s) array_init(&(s->commits), sizeof(commit_t)); - s->qcow_filename = qemu_malloc(1024); + s->qcow_filename = g_malloc(1024); get_tmp_filename(s->qcow_filename, 1024); bdrv_qcow = bdrv_find_format("qcow"); @@ -2822,7 +2822,7 @@ static int enable_write_target(BDRVVVFATState *s) s->bs->backing_hd = calloc(sizeof(BlockDriverState), 1); s->bs->backing_hd->drv = &vvfat_write_target; - s->bs->backing_hd->opaque = qemu_malloc(sizeof(void*)); + s->bs->backing_hd->opaque = g_malloc(sizeof(void*)); *(void**)s->bs->backing_hd->opaque = s; return 0; |