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>
This commit is contained in:
Anthony Liguori
2011-08-20 22:09:37 -05:00
parent 14015304b6
commit 7267c0947d
357 changed files with 1672 additions and 1674 deletions

View File

@@ -22,7 +22,7 @@ int v9fs_co_readlink(V9fsState *s, V9fsString *path, V9fsString *buf)
int err;
ssize_t len;
buf->data = qemu_malloc(PATH_MAX);
buf->data = g_malloc(PATH_MAX);
v9fs_co_run_in_worker(
{
len = s->ops->readlink(&s->ctx, path->data,
@@ -36,7 +36,7 @@ int v9fs_co_readlink(V9fsState *s, V9fsString *path, V9fsString *buf)
}
});
if (err) {
qemu_free(buf->data);
g_free(buf->data);
buf->data = NULL;
buf->size = 0;
}

View File

@@ -36,12 +36,12 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
struct virtio_9p_config *cfg;
V9fsState *s = to_virtio_9p(vdev);
cfg = qemu_mallocz(sizeof(struct virtio_9p_config) +
cfg = g_malloc0(sizeof(struct virtio_9p_config) +
s->tag_len);
stw_raw(&cfg->tag_len, s->tag_len);
memcpy(cfg->tag, s->tag, s->tag_len);
memcpy(config, cfg, s->config_size);
qemu_free(cfg);
g_free(cfg);
}
VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
@@ -114,13 +114,13 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
exit(1);
}
s->ctx.fs_root = qemu_strdup(fse->path);
s->ctx.fs_root = g_strdup(fse->path);
len = strlen(conf->tag);
if (len > MAX_TAG_LEN) {
len = MAX_TAG_LEN;
}
/* s->tag is non-NULL terminated string */
s->tag = qemu_malloc(len);
s->tag = g_malloc(len);
memcpy(s->tag, conf->tag, len);
s->tag_len = len;
s->ctx.uid = -1;

View File

@@ -79,7 +79,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path,
}
/* Now fetch the xattr and find the actual size */
orig_value = qemu_malloc(xattr_len);
orig_value = g_malloc(xattr_len);
xattr_len = llistxattr(rpath(ctx, path, buffer), orig_value, xattr_len);
/* store the orig pointer */
@@ -111,7 +111,7 @@ next_entry:
}
err_out:
qemu_free(orig_value_start);
g_free(orig_value_start);
return size;
}

View File

@@ -239,7 +239,7 @@ static void v9fs_string_init(V9fsString *str)
static void v9fs_string_free(V9fsString *str)
{
qemu_free(str->data);
g_free(str->data);
str->data = NULL;
str->size = 0;
}
@@ -338,7 +338,7 @@ v9fs_string_alloc_printf(char **strp, const char *fmt, va_list ap)
}
alloc_print:
*strp = qemu_malloc((len + 1) * sizeof(**strp));
*strp = g_malloc((len + 1) * sizeof(**strp));
return vsprintf(*strp, fmt, ap);
}
@@ -408,7 +408,7 @@ static V9fsFidState *alloc_fid(V9fsState *s, int32_t fid)
return NULL;
}
f = qemu_mallocz(sizeof(V9fsFidState));
f = g_malloc0(sizeof(V9fsFidState));
f->fid = fid;
f->fid_type = P9_FID_NONE;
@@ -448,7 +448,7 @@ free_out:
v9fs_string_free(&fidp->fs.xattr.name);
free_value:
if (fidp->fs.xattr.value) {
qemu_free(fidp->fs.xattr.value);
g_free(fidp->fs.xattr.value);
}
return retval;
}
@@ -479,7 +479,7 @@ static int free_fid(V9fsState *s, int32_t fid)
retval = v9fs_xattr_fid_clunk(s, fidp);
}
v9fs_string_free(&fidp->path);
qemu_free(fidp);
g_free(fidp);
return retval;
}
@@ -685,7 +685,7 @@ static size_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
V9fsString *str = va_arg(ap, V9fsString *);
offset += pdu_unmarshal(pdu, offset, "w", &str->size);
/* FIXME: sanity check str->size */
str->data = qemu_malloc(str->size + 1);
str->data = g_malloc(str->size + 1);
offset += pdu_unpack(str->data, pdu, offset, str->size);
str->data[str->size] = 0;
break;
@@ -1209,7 +1209,7 @@ static void v9fs_stat_post_lstat(V9fsState *s, V9fsStatState *vs, int err)
out:
complete_pdu(s, vs->pdu, err);
v9fs_stat_free(&vs->v9stat);
qemu_free(vs);
g_free(vs);
}
static void v9fs_stat(void *opaque)
@@ -1220,7 +1220,7 @@ static void v9fs_stat(void *opaque)
V9fsStatState *vs;
ssize_t err = 0;
vs = qemu_malloc(sizeof(*vs));
vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
@@ -1241,7 +1241,7 @@ static void v9fs_stat(void *opaque)
out:
complete_pdu(s, vs->pdu, err);
v9fs_stat_free(&vs->v9stat);
qemu_free(vs);
g_free(vs);
}
static void v9fs_getattr(void *opaque)
@@ -1379,8 +1379,8 @@ static void v9fs_walk_complete(V9fsState *s, V9fsWalkState *vs, int err)
v9fs_string_free(&vs->wnames[vs->name_idx]);
}
qemu_free(vs->wnames);
qemu_free(vs->qids);
g_free(vs->wnames);
g_free(vs->qids);
}
}
@@ -1463,7 +1463,7 @@ static void v9fs_walk(void *opaque)
int err = 0;
int i;
vs = qemu_malloc(sizeof(*vs));
vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->wnames = NULL;
vs->qids = NULL;
@@ -1473,9 +1473,9 @@ static void v9fs_walk(void *opaque)
&newfid, &vs->nwnames);
if (vs->nwnames && vs->nwnames <= P9_MAXWELEM) {
vs->wnames = qemu_mallocz(sizeof(vs->wnames[0]) * vs->nwnames);
vs->wnames = g_malloc0(sizeof(vs->wnames[0]) * vs->nwnames);
vs->qids = qemu_mallocz(sizeof(vs->qids[0]) * vs->nwnames);
vs->qids = g_malloc0(sizeof(vs->qids[0]) * vs->nwnames);
for (i = 0; i < vs->nwnames; i++) {
vs->offset += pdu_unmarshal(vs->pdu, vs->offset, "s",
@@ -1568,7 +1568,7 @@ static void v9fs_open_post_opendir(V9fsState *s, V9fsOpenState *vs, int err)
err = vs->offset;
out:
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
@@ -1578,7 +1578,7 @@ static void v9fs_open_post_getiounit(V9fsState *s, V9fsOpenState *vs)
vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, vs->iounit);
err = vs->offset;
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_open_post_open(V9fsState *s, V9fsOpenState *vs, int err)
@@ -1593,7 +1593,7 @@ static void v9fs_open_post_open(V9fsState *s, V9fsOpenState *vs, int err)
return;
out:
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_open_post_lstat(V9fsState *s, V9fsOpenState *vs, int err)
@@ -1625,7 +1625,7 @@ static void v9fs_open_post_lstat(V9fsState *s, V9fsOpenState *vs, int err)
return;
out:
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_open(void *opaque)
@@ -1636,7 +1636,7 @@ static void v9fs_open(void *opaque)
V9fsOpenState *vs;
ssize_t err = 0;
vs = qemu_malloc(sizeof(*vs));
vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
vs->mode = 0;
@@ -1661,7 +1661,7 @@ static void v9fs_open(void *opaque)
return;
out:
complete_pdu(s, pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_post_lcreate(V9fsState *s, V9fsLcreateState *vs, int err)
@@ -1683,7 +1683,7 @@ static void v9fs_post_lcreate(V9fsState *s, V9fsLcreateState *vs, int err)
complete_pdu(s, vs->pdu, err);
v9fs_string_free(&vs->name);
v9fs_string_free(&vs->fullname);
qemu_free(vs);
g_free(vs);
}
static void v9fs_lcreate_post_get_iounit(V9fsState *s, V9fsLcreateState *vs,
@@ -1724,7 +1724,7 @@ static void v9fs_lcreate(void *opaque)
V9fsLcreateState *vs;
ssize_t err = 0;
vs = qemu_malloc(sizeof(*vs));
vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
@@ -1753,7 +1753,7 @@ static void v9fs_lcreate(void *opaque)
out:
complete_pdu(s, vs->pdu, err);
v9fs_string_free(&vs->name);
qemu_free(vs);
g_free(vs);
}
static void v9fs_post_do_fsync(V9fsState *s, V9fsPDU *pdu, int err)
@@ -1820,7 +1820,7 @@ out:
complete_pdu(s, vs->pdu, err);
v9fs_stat_free(&vs->v9stat);
v9fs_string_free(&vs->name);
qemu_free(vs);
g_free(vs);
return;
}
@@ -1874,7 +1874,7 @@ static void v9fs_read_post_readdir(V9fsState *s, V9fsReadState *vs, ssize_t err)
vs->offset += vs->count;
err = vs->offset;
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
return;
}
@@ -1925,7 +1925,7 @@ static void v9fs_read_post_preadv(V9fsState *s, V9fsReadState *vs, ssize_t err)
out:
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_xattr_read(V9fsState *s, V9fsReadState *vs)
@@ -1950,7 +1950,7 @@ static void v9fs_xattr_read(V9fsState *s, V9fsReadState *vs)
read_count);
err = vs->offset;
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_read(void *opaque)
@@ -1961,7 +1961,7 @@ static void v9fs_read(void *opaque)
V9fsReadState *vs;
ssize_t err = 0;
vs = qemu_malloc(sizeof(*vs));
vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
vs->total = 0;
@@ -2006,7 +2006,7 @@ static void v9fs_read(void *opaque)
}
out:
complete_pdu(s, pdu, err);
qemu_free(vs);
g_free(vs);
}
static size_t v9fs_readdir_data_size(V9fsString *name)
@@ -2138,7 +2138,7 @@ static void v9fs_write_post_pwritev(V9fsState *s, V9fsWriteState *vs,
err = vs->offset;
out:
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_xattr_write(V9fsState *s, V9fsWriteState *vs)
@@ -2180,7 +2180,7 @@ static void v9fs_xattr_write(V9fsState *s, V9fsWriteState *vs)
}
out:
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_write(void *opaque)
@@ -2191,7 +2191,7 @@ static void v9fs_write(void *opaque)
V9fsWriteState *vs;
ssize_t err;
vs = qemu_malloc(sizeof(*vs));
vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
@@ -2235,7 +2235,7 @@ static void v9fs_write(void *opaque)
return;
out:
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_create_post_getiounit(V9fsState *s, V9fsCreateState *vs)
@@ -2251,7 +2251,7 @@ static void v9fs_create_post_getiounit(V9fsState *s, V9fsCreateState *vs)
v9fs_string_free(&vs->name);
v9fs_string_free(&vs->extension);
v9fs_string_free(&vs->fullname);
qemu_free(vs);
g_free(vs);
}
static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
@@ -2266,7 +2266,7 @@ static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
v9fs_string_free(&vs->name);
v9fs_string_free(&vs->extension);
v9fs_string_free(&vs->fullname);
qemu_free(vs);
g_free(vs);
}
static void v9fs_create_post_perms(V9fsState *s, V9fsCreateState *vs, int err)
@@ -2426,7 +2426,7 @@ static void v9fs_create(void *opaque)
V9fsCreateState *vs;
int err = 0;
vs = qemu_malloc(sizeof(*vs));
vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
@@ -2452,7 +2452,7 @@ out:
complete_pdu(s, vs->pdu, err);
v9fs_string_free(&vs->name);
v9fs_string_free(&vs->extension);
qemu_free(vs);
g_free(vs);
}
static void v9fs_post_symlink(V9fsState *s, V9fsSymlinkState *vs, int err)
@@ -2468,7 +2468,7 @@ static void v9fs_post_symlink(V9fsState *s, V9fsSymlinkState *vs, int err)
v9fs_string_free(&vs->name);
v9fs_string_free(&vs->symname);
v9fs_string_free(&vs->fullname);
qemu_free(vs);
g_free(vs);
}
static void v9fs_symlink_post_do_symlink(V9fsState *s, V9fsSymlinkState *vs,
@@ -2491,7 +2491,7 @@ static void v9fs_symlink(void *opaque)
int err = 0;
gid_t gid;
vs = qemu_malloc(sizeof(*vs));
vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
@@ -2517,7 +2517,7 @@ out:
complete_pdu(s, vs->pdu, err);
v9fs_string_free(&vs->name);
v9fs_string_free(&vs->symname);
qemu_free(vs);
g_free(vs);
}
static void v9fs_flush(void *opaque)
@@ -2605,7 +2605,7 @@ static void v9fs_wstat_post_truncate(V9fsState *s, V9fsWstatState *vs, int err)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_wstat_post_rename(V9fsState *s, V9fsWstatState *vs, int err)
@@ -2624,7 +2624,7 @@ static void v9fs_wstat_post_rename(V9fsState *s, V9fsWstatState *vs, int err)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static int v9fs_complete_rename(V9fsState *s, V9fsFidState *fidp,
@@ -2643,7 +2643,7 @@ static int v9fs_complete_rename(V9fsState *s, V9fsFidState *fidp,
}
BUG_ON(dirfidp->fid_type != P9_FID_NONE);
new_name = qemu_mallocz(dirfidp->path.size + name->size + 2);
new_name = g_malloc0(dirfidp->path.size + name->size + 2);
strcpy(new_name, dirfidp->path.data);
strcat(new_name, "/");
@@ -2656,7 +2656,7 @@ static int v9fs_complete_rename(V9fsState *s, V9fsFidState *fidp,
} else {
end = old_name;
}
new_name = qemu_mallocz(end - old_name + name->size + 1);
new_name = g_malloc0(end - old_name + name->size + 1);
strncat(new_name, old_name, end - old_name);
strncat(new_name + (end - old_name), name->data, name->size);
@@ -2710,7 +2710,7 @@ static void v9fs_wstat_post_chown(V9fsState *s, V9fsWstatState *vs, int err)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_rename(void *opaque)
@@ -2760,7 +2760,7 @@ static void v9fs_wstat_post_utime(V9fsState *s, V9fsWstatState *vs, int err)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_wstat_post_chmod(V9fsState *s, V9fsWstatState *vs, int err)
@@ -2795,7 +2795,7 @@ static void v9fs_wstat_post_chmod(V9fsState *s, V9fsWstatState *vs, int err)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_wstat_post_fsync(V9fsState *s, V9fsWstatState *vs, int err)
@@ -2805,7 +2805,7 @@ static void v9fs_wstat_post_fsync(V9fsState *s, V9fsWstatState *vs, int err)
}
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_wstat_post_lstat(V9fsState *s, V9fsWstatState *vs, int err)
@@ -2836,7 +2836,7 @@ static void v9fs_wstat_post_lstat(V9fsState *s, V9fsWstatState *vs, int err)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static void v9fs_wstat(void *opaque)
@@ -2847,7 +2847,7 @@ static void v9fs_wstat(void *opaque)
V9fsWstatState *vs;
int err = 0;
vs = qemu_malloc(sizeof(*vs));
vs = g_malloc(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
@@ -2878,7 +2878,7 @@ static void v9fs_wstat(void *opaque)
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
g_free(vs);
}
static int v9fs_fill_statfs(V9fsState *s, V9fsPDU *pdu, struct statfs *stbuf)
@@ -3014,11 +3014,11 @@ static void v9fs_lock(void *opaque)
int32_t fid, err = 0;
V9fsLockState *vs;
vs = qemu_mallocz(sizeof(*vs));
vs = g_malloc0(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
vs->flock = qemu_malloc(sizeof(*vs->flock));
vs->flock = g_malloc(sizeof(*vs->flock));
pdu_unmarshal(vs->pdu, vs->offset, "dbdqqds", &fid, &vs->flock->type,
&vs->flock->flags, &vs->flock->start, &vs->flock->length,
&vs->flock->proc_id, &vs->flock->client_id);
@@ -3045,8 +3045,8 @@ static void v9fs_lock(void *opaque)
out:
vs->offset += pdu_marshal(vs->pdu, vs->offset, "b", vs->status);
complete_pdu(s, vs->pdu, err);
qemu_free(vs->flock);
qemu_free(vs);
g_free(vs->flock);
g_free(vs);
}
/*
@@ -3061,11 +3061,11 @@ static void v9fs_getlock(void *opaque)
int32_t fid, err = 0;
V9fsGetlockState *vs;
vs = qemu_mallocz(sizeof(*vs));
vs = g_malloc0(sizeof(*vs));
vs->pdu = pdu;
vs->offset = 7;
vs->glock = qemu_malloc(sizeof(*vs->glock));
vs->glock = g_malloc(sizeof(*vs->glock));
pdu_unmarshal(vs->pdu, vs->offset, "dbqqds", &fid, &vs->glock->type,
&vs->glock->start, &vs->glock->length, &vs->glock->proc_id,
&vs->glock->client_id);
@@ -3087,8 +3087,8 @@ static void v9fs_getlock(void *opaque)
&vs->glock->client_id);
out:
complete_pdu(s, vs->pdu, err);
qemu_free(vs->glock);
qemu_free(vs);
g_free(vs->glock);
g_free(vs);
}
static void v9fs_mkdir(void *opaque)
@@ -3171,7 +3171,7 @@ static void v9fs_xattrwalk(void *opaque)
xattr_fidp->fid_type = P9_FID_XATTR;
xattr_fidp->fs.xattr.copied_len = -1;
if (size) {
xattr_fidp->fs.xattr.value = qemu_malloc(size);
xattr_fidp->fs.xattr.value = g_malloc(size);
err = v9fs_co_llistxattr(s, &xattr_fidp->path,
xattr_fidp->fs.xattr.value,
xattr_fidp->fs.xattr.len);
@@ -3201,7 +3201,7 @@ static void v9fs_xattrwalk(void *opaque)
xattr_fidp->fid_type = P9_FID_XATTR;
xattr_fidp->fs.xattr.copied_len = -1;
if (size) {
xattr_fidp->fs.xattr.value = qemu_malloc(size);
xattr_fidp->fs.xattr.value = g_malloc(size);
err = v9fs_co_lgetxattr(s, &xattr_fidp->path,
&name, xattr_fidp->fs.xattr.value,
xattr_fidp->fs.xattr.len);
@@ -3248,7 +3248,7 @@ static void v9fs_xattrcreate(void *opaque)
v9fs_string_init(&xattr_fidp->fs.xattr.name);
v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
if (size) {
xattr_fidp->fs.xattr.value = qemu_malloc(size);
xattr_fidp->fs.xattr.value = g_malloc(size);
} else {
xattr_fidp->fs.xattr.value = NULL;
}

View File

@@ -100,13 +100,13 @@ int acpi_table_add(const char *t)
if (!acpi_tables) {
allen = sizeof(uint16_t);
acpi_tables = qemu_mallocz(allen);
acpi_tables = g_malloc0(allen);
} else {
allen = acpi_tables_len;
}
start = allen;
acpi_tables = qemu_realloc(acpi_tables, start + ACPI_TABLE_HDR_SIZE);
acpi_tables = g_realloc(acpi_tables, start + ACPI_TABLE_HDR_SIZE);
allen += has_header ? ACPI_TABLE_PFX_SIZE : ACPI_TABLE_HDR_SIZE;
/* now read in the data files, reallocating buffer as needed */
@@ -125,7 +125,7 @@ int acpi_table_add(const char *t)
if (r == 0) {
break;
} else if (r > 0) {
acpi_tables = qemu_realloc(acpi_tables, allen + r);
acpi_tables = g_realloc(acpi_tables, allen + r);
memcpy(acpi_tables + allen, data, r);
allen += r;
} else if (errno != EINTR) {
@@ -379,8 +379,8 @@ void acpi_pm1_cnt_reset(ACPIPM1CNT *pm1_cnt)
void acpi_gpe_init(ACPIGPE *gpe, uint8_t len)
{
gpe->len = len;
gpe->sts = qemu_mallocz(len / 2);
gpe->en = qemu_mallocz(len / 2);
gpe->sts = g_malloc0(len / 2);
gpe->en = g_malloc0(len / 2);
}
void acpi_gpe_blk(ACPIGPE *gpe, uint32_t blk)

View File

@@ -290,7 +290,7 @@ void adb_kbd_init(ADBBusState *bus)
{
ADBDevice *d;
KBDState *s;
s = qemu_mallocz(sizeof(KBDState));
s = g_malloc0(sizeof(KBDState));
d = adb_register_device(bus, ADB_KEYBOARD, adb_kbd_request,
adb_kbd_reset, s);
qemu_add_kbd_event_handler(adb_kbd_put_keycode, d);
@@ -447,7 +447,7 @@ void adb_mouse_init(ADBBusState *bus)
ADBDevice *d;
MouseState *s;
s = qemu_mallocz(sizeof(MouseState));
s = g_malloc0(sizeof(MouseState));
d = adb_register_device(bus, ADB_MOUSE, adb_mouse_request,
adb_mouse_reset, s);
qemu_add_mouse_event_handler(adb_mouse_event, d, 0, "QEMU ADB Mouse");

View File

@@ -268,7 +268,7 @@ static void Adlib_fini (AdlibState *s)
#endif
if (s->mixbuf) {
qemu_free (s->mixbuf);
g_free (s->mixbuf);
}
s->active = 0;
@@ -323,7 +323,7 @@ int Adlib_init (qemu_irq *pic)
}
s->samples = AUD_get_buffer_size_out (s->voice) >> SHIFT;
s->mixbuf = qemu_mallocz (s->samples << SHIFT);
s->mixbuf = g_malloc0 (s->samples << SHIFT);
register_ioport_read (0x388, 4, 1, adlib_read, s);
register_ioport_write (0x388, 4, 1, adlib_write, s);

View File

@@ -170,7 +170,7 @@ static void applesmc_add_key(struct AppleSMCStatus *s, const char *key,
{
struct AppleSMCData *def;
def = qemu_mallocz(sizeof(struct AppleSMCData));
def = g_malloc0(sizeof(struct AppleSMCData));
def->key = key;
def->len = len;
def->data = data;

View File

@@ -159,7 +159,7 @@ static arm_timer_state *arm_timer_init(uint32_t freq)
arm_timer_state *s;
QEMUBH *bh;
s = (arm_timer_state *)qemu_mallocz(sizeof(arm_timer_state));
s = (arm_timer_state *)g_malloc0(sizeof(arm_timer_state));
s->freq = freq;
s->control = TIMER_CTRL_IE;

View File

@@ -315,7 +315,7 @@ void axisdev88_init (ram_addr_t ram_size,
}
/* Add the two ethernet blocks. */
dma_eth = qemu_mallocz(sizeof dma_eth[0] * 4); /* Allocate 4 channels. */
dma_eth = g_malloc0(sizeof dma_eth[0] * 4); /* Allocate 4 channels. */
etraxfs_eth_init(&nd_table[0], 0x30034000, 1, &dma_eth[0], &dma_eth[1]);
if (nb_nics > 1) {
etraxfs_eth_init(&nd_table[1], 0x30036000, 2, &dma_eth[2], &dma_eth[3]);

View File

@@ -559,7 +559,7 @@ static void baum_chr_read(void *opaque)
if (ret == -1 && (brlapi_errno != BRLAPI_ERROR_LIBCERR || errno != EINTR)) {
brlapi_perror("baum: brlapi_readKey");
brlapi__closeConnection(baum->brlapi);
qemu_free(baum->brlapi);
g_free(baum->brlapi);
baum->brlapi = NULL;
}
}
@@ -571,9 +571,9 @@ static void baum_close(struct CharDriverState *chr)
qemu_free_timer(baum->cellCount_timer);
if (baum->brlapi) {
brlapi__closeConnection(baum->brlapi);
qemu_free(baum->brlapi);
g_free(baum->brlapi);
}
qemu_free(baum);
g_free(baum);
}
int chr_baum_init(QemuOpts *opts, CharDriverState **_chr)
@@ -586,8 +586,8 @@ int chr_baum_init(QemuOpts *opts, CharDriverState **_chr)
#endif
int tty;
baum = qemu_mallocz(sizeof(BaumDriverState));
baum->chr = chr = qemu_mallocz(sizeof(CharDriverState));
baum = g_malloc0(sizeof(BaumDriverState));
baum->chr = chr = g_malloc0(sizeof(CharDriverState));
chr->opaque = baum;
chr->chr_write = baum_write;
@@ -595,7 +595,7 @@ int chr_baum_init(QemuOpts *opts, CharDriverState **_chr)
chr->chr_accept_input = baum_accept_input;
chr->chr_close = baum_close;
handle = qemu_mallocz(brlapi_getHandleSize());
handle = g_malloc0(brlapi_getHandleSize());
baum->brlapi = handle;
baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL);
@@ -636,8 +636,8 @@ fail:
qemu_free_timer(baum->cellCount_timer);
brlapi__closeConnection(handle);
fail_handle:
qemu_free(handle);
qemu_free(chr);
qemu_free(baum);
g_free(handle);
g_free(chr);
g_free(baum);
return -EIO;
}

View File

@@ -171,7 +171,7 @@ bitbang_i2c_interface *bitbang_i2c_init(i2c_bus *bus)
{
bitbang_i2c_interface *s;
s = qemu_mallocz(sizeof(bitbang_i2c_interface));
s = g_malloc0(sizeof(bitbang_i2c_interface));
s->bus = bus;
s->last_data = 1;

View File

@@ -188,7 +188,7 @@ static int blizzard_transfer_setup(BlizzardState *s)
s->data.len = s->bpp * s->data.dx * s->data.dy;
s->data.pitch = s->data.dx;
if (s->data.len > s->data.buflen) {
s->data.buf = qemu_realloc(s->data.buf, s->data.len);
s->data.buf = g_realloc(s->data.buf, s->data.len);
s->data.buflen = s->data.len;
}
s->data.ptr = s->data.buf;
@@ -953,9 +953,9 @@ static void blizzard_screen_dump(void *opaque, const char *filename) {
void *s1d13745_init(qemu_irq gpio_int)
{
BlizzardState *s = (BlizzardState *) qemu_mallocz(sizeof(*s));
BlizzardState *s = (BlizzardState *) g_malloc0(sizeof(*s));
s->fb = qemu_malloc(0x180000);
s->fb = g_malloc(0x180000);
s->state = graphic_console_init(blizzard_update_display,
blizzard_invalidate_display,
@@ -964,7 +964,7 @@ void *s1d13745_init(qemu_irq gpio_int)
switch (ds_get_bits_per_pixel(s->state)) {
case 0:
s->line_fn_tab[0] = s->line_fn_tab[1] =
qemu_mallocz(sizeof(blizzard_fn_t) * 0x10);
g_malloc0(sizeof(blizzard_fn_t) * 0x10);
break;
case 8:
s->line_fn_tab[0] = blizzard_draw_fn_8;

View File

@@ -434,7 +434,7 @@ qemu_irq *csrhci_pins_get(CharDriverState *chr)
CharDriverState *uart_hci_init(qemu_irq wakeup)
{
struct csrhci_s *s = (struct csrhci_s *)
qemu_mallocz(sizeof(struct csrhci_s));
g_malloc0(sizeof(struct csrhci_s));
s->chr.opaque = s;
s->chr.chr_write = csrhci_write;

View File

@@ -721,7 +721,7 @@ static void bt_hci_connection_reject_event(struct bt_hci_s *hci,
static void bt_hci_connection_accept(struct bt_hci_s *hci,
struct bt_device_s *host)
{
struct bt_hci_link_s *link = qemu_mallocz(sizeof(struct bt_hci_link_s));
struct bt_hci_link_s *link = g_malloc0(sizeof(struct bt_hci_link_s));
evt_conn_complete params;
uint16_t handle;
uint8_t status = HCI_SUCCESS;
@@ -736,7 +736,7 @@ static void bt_hci_connection_accept(struct bt_hci_s *hci,
tries);
if (!tries) {
qemu_free(link);
g_free(link);
bt_hci_connection_reject(hci, host, HCI_REJECTED_LIMITED_RESOURCES);
status = HCI_NO_CONNECTION;
goto complete;
@@ -893,7 +893,7 @@ static void bt_hci_disconnect(struct bt_hci_s *hci,
/* We are the slave, we get to clean this burden */
link = (struct bt_hci_link_s *) btlink;
qemu_free(link);
g_free(link);
complete:
bt_hci_lmp_link_teardown(hci, handle);
@@ -928,7 +928,7 @@ static void bt_hci_lmp_disconnect_slave(struct bt_link_s *btlink)
uint16_t handle = link->handle;
evt_disconn_complete params;
qemu_free(link);
g_free(link);
bt_hci_lmp_link_teardown(hci, handle);
@@ -1138,7 +1138,7 @@ static void bt_hci_reset(struct bt_hci_s *hci)
hci->device.inquiry_scan = 0;
hci->device.page_scan = 0;
if (hci->device.lmp_name)
qemu_free((void *) hci->device.lmp_name);
g_free((void *) hci->device.lmp_name);
hci->device.lmp_name = NULL;
hci->device.class[0] = 0x00;
hci->device.class[1] = 0x00;
@@ -1816,8 +1816,8 @@ static void bt_submit_hci(struct HCIInfo *info,
LENGTH_CHECK(change_local_name);
if (hci->device.lmp_name)
qemu_free((void *) hci->device.lmp_name);
hci->device.lmp_name = qemu_strndup(PARAM(change_local_name, name),
g_free((void *) hci->device.lmp_name);
hci->device.lmp_name = g_strndup(PARAM(change_local_name, name),
sizeof(PARAM(change_local_name, name)));
bt_hci_event_complete_status(hci, HCI_SUCCESS);
break;
@@ -2143,7 +2143,7 @@ static void bt_hci_destroy(struct bt_device_s *dev)
struct HCIInfo *bt_new_hci(struct bt_scatternet_s *net)
{
struct bt_hci_s *s = qemu_mallocz(sizeof(struct bt_hci_s));
struct bt_hci_s *s = g_malloc0(sizeof(struct bt_hci_s));
s->lm.inquiry_done = qemu_new_timer_ns(vm_clock, bt_hci_inquiry_done, s);
s->lm.inquiry_next = qemu_new_timer_ns(vm_clock, bt_hci_inquiry_next, s);
@@ -2188,7 +2188,7 @@ static void bt_hci_done(struct HCIInfo *info)
bt_device_done(&hci->device);
if (hci->device.lmp_name)
qemu_free((void *) hci->device.lmp_name);
g_free((void *) hci->device.lmp_name);
/* Be gentle and send DISCONNECT to all connected peers and those
* currently waiting for us to accept or reject a connection request.
@@ -2217,5 +2217,5 @@ static void bt_hci_done(struct HCIInfo *info)
qemu_free_timer(hci->lm.inquiry_next);
qemu_free_timer(hci->conn_accept_timer);
qemu_free(hci);
g_free(hci);
}

View File

@@ -504,7 +504,7 @@ static void bt_hid_destroy(struct bt_device_s *dev)
hid_free(&hid->hid);
qemu_free(hid);
g_free(hid);
}
enum peripheral_minor_class {
@@ -517,7 +517,7 @@ enum peripheral_minor_class {
static struct bt_device_s *bt_hid_init(struct bt_scatternet_s *net,
enum peripheral_minor_class minor)
{
struct bt_hid_device_s *s = qemu_mallocz(sizeof(*s));
struct bt_hid_device_s *s = g_malloc0(sizeof(*s));
uint32_t class =
/* Format type */
(0 << 0) |

View File

@@ -410,7 +410,7 @@ static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap,
if (psm_info) {
/* Device supports this use-case. */
ch = qemu_mallocz(sizeof(*ch));
ch = g_malloc0(sizeof(*ch));
ch->params.sdu_out = l2cap_bframe_out;
ch->params.sdu_submit = l2cap_bframe_submit;
ch->frame_in = l2cap_bframe_in;
@@ -428,7 +428,7 @@ static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap,
result = L2CAP_CR_SUCCESS;
status = L2CAP_CS_NO_INFO;
} else {
qemu_free(ch);
g_free(ch);
result = L2CAP_CR_NO_MEM;
status = L2CAP_CS_NO_INFO;
@@ -473,7 +473,7 @@ static void l2cap_channel_close(struct l2cap_instance_s *l2cap,
l2cap->cid[cid] = NULL;
ch->params.close(ch->params.opaque);
qemu_free(ch);
g_free(ch);
}
l2cap_disconnection_response(l2cap, cid, source_cid);
@@ -1218,13 +1218,13 @@ static void l2cap_teardown(struct l2cap_instance_s *l2cap, int send_disconnect)
for (cid = L2CAP_CID_ALLOC; cid < L2CAP_CID_MAX; cid ++)
if (l2cap->cid[cid]) {
l2cap->cid[cid]->params.close(l2cap->cid[cid]->params.opaque);
qemu_free(l2cap->cid[cid]);
g_free(l2cap->cid[cid]);
}
if (l2cap->role)
qemu_free(l2cap);
g_free(l2cap);
else
qemu_free(l2cap->link);
g_free(l2cap->link);
}
/* L2CAP glue to lower layers in bluetooth stack (LMP) */
@@ -1236,7 +1236,7 @@ static void l2cap_lmp_connection_request(struct bt_link_s *link)
/* Always accept - we only get called if (dev->device->page_scan). */
l2cap = qemu_mallocz(sizeof(struct slave_l2cap_instance_s));
l2cap = g_malloc0(sizeof(struct slave_l2cap_instance_s));
l2cap->link.slave = &dev->device;
l2cap->link.host = link->host;
l2cap_init(&l2cap->l2cap, &l2cap->link, 0);
@@ -1257,7 +1257,7 @@ static void l2cap_lmp_connection_complete(struct bt_link_s *link)
return;
}
l2cap = qemu_mallocz(sizeof(struct l2cap_instance_s));
l2cap = g_malloc0(sizeof(struct l2cap_instance_s));
l2cap_init(l2cap, link, 1);
link->acl_mode = acl_active;
@@ -1353,7 +1353,7 @@ void bt_l2cap_psm_register(struct bt_l2cap_device_s *dev, int psm, int min_mtu,
exit(-1);
}
new_psm = qemu_mallocz(sizeof(*new_psm));
new_psm = g_malloc0(sizeof(*new_psm));
new_psm->psm = psm;
new_psm->min_mtu = min_mtu;
new_psm->new_channel = new_channel;

View File

@@ -567,12 +567,12 @@ static void bt_l2cap_sdp_close_ch(void *opaque)
int i;
for (i = 0; i < sdp->services; i ++) {
qemu_free(sdp->service_list[i].attribute_list->pair);
qemu_free(sdp->service_list[i].attribute_list);
qemu_free(sdp->service_list[i].uuid);
g_free(sdp->service_list[i].attribute_list->pair);
g_free(sdp->service_list[i].attribute_list);
g_free(sdp->service_list[i].uuid);
}
qemu_free(sdp->service_list);
qemu_free(sdp);
g_free(sdp->service_list);
g_free(sdp);
}
struct sdp_def_service_s {
@@ -709,10 +709,10 @@ static void sdp_service_record_build(struct sdp_service_record_s *record,
}
record->uuids = 1 << ffs(record->uuids - 1);
record->attribute_list =
qemu_mallocz(record->attributes * sizeof(*record->attribute_list));
g_malloc0(record->attributes * sizeof(*record->attribute_list));
record->uuid =
qemu_mallocz(record->uuids * sizeof(*record->uuid));
data = qemu_malloc(len);
g_malloc0(record->uuids * sizeof(*record->uuid));
data = g_malloc(len);
record->attributes = 0;
uuid = record->uuid;
@@ -753,7 +753,7 @@ static void sdp_service_db_build(struct bt_l2cap_sdp_state_s *sdp,
while (service[sdp->services])
sdp->services ++;
sdp->service_list =
qemu_mallocz(sdp->services * sizeof(*sdp->service_list));
g_malloc0(sdp->services * sizeof(*sdp->service_list));
sdp->services = 0;
while (*service) {
@@ -942,7 +942,7 @@ SERVICE(pnp,
static int bt_l2cap_sdp_new_ch(struct bt_l2cap_device_s *dev,
struct bt_l2cap_conn_params_s *params)
{
struct bt_l2cap_sdp_state_s *sdp = qemu_mallocz(sizeof(*sdp));
struct bt_l2cap_sdp_state_s *sdp = g_malloc0(sizeof(*sdp));
struct sdp_def_service_s *services[] = {
&sdp_service_sdp_s,
&sdp_service_hid_s,

View File

@@ -54,7 +54,7 @@ static void bt_dummy_lmp_acl_resp(struct bt_link_s *link,
/* Slaves that don't hold any additional per link state can use these */
static void bt_dummy_lmp_connection_request(struct bt_link_s *req)
{
struct bt_link_s *link = qemu_mallocz(sizeof(struct bt_link_s));
struct bt_link_s *link = g_malloc0(sizeof(struct bt_link_s));
link->slave = req->slave;
link->host = req->host;
@@ -65,13 +65,13 @@ static void bt_dummy_lmp_connection_request(struct bt_link_s *req)
static void bt_dummy_lmp_disconnect_slave(struct bt_link_s *link)
{
qemu_free(link);
g_free(link);
}
static void bt_dummy_destroy(struct bt_device_s *device)
{
bt_device_done(device);
qemu_free(device);
g_free(device);
}
static int bt_dev_idx = 0;

View File

@@ -132,7 +132,7 @@ static void cbus_sel(void *opaque, int line, int level)
CBus *cbus_init(qemu_irq dat)
{
CBusPriv *s = (CBusPriv *) qemu_mallocz(sizeof(*s));
CBusPriv *s = (CBusPriv *) g_malloc0(sizeof(*s));
s->dat_out = dat;
s->cbus.clk = qemu_allocate_irqs(cbus_clk, s, 1)[0];
@@ -387,7 +387,7 @@ static void retu_io(void *opaque, int rw, int reg, uint16_t *val)
void *retu_init(qemu_irq irq, int vilma)
{
CBusRetu *s = (CBusRetu *) qemu_mallocz(sizeof(*s));
CBusRetu *s = (CBusRetu *) g_malloc0(sizeof(*s));
s->irq = irq;
s->irqen = 0xffff;
@@ -603,7 +603,7 @@ static void tahvo_io(void *opaque, int rw, int reg, uint16_t *val)
void *tahvo_init(qemu_irq irq, int betty)
{
CBusTahvo *s = (CBusTahvo *) qemu_mallocz(sizeof(*s));
CBusTahvo *s = (CBusTahvo *) g_malloc0(sizeof(*s));
s->irq = irq;
s->irqen = 0xffff;

View File

@@ -135,7 +135,7 @@ static void emulated_apdu_from_guest(CCIDCardState *base,
const uint8_t *apdu, uint32_t len)
{
EmulatedState *card = DO_UPCAST(EmulatedState, base, base);
EmulEvent *event = (EmulEvent *)qemu_malloc(sizeof(EmulEvent) + len);
EmulEvent *event = (EmulEvent *)g_malloc(sizeof(EmulEvent) + len);
assert(event);
event->p.data.type = EMUL_GUEST_APDU;
@@ -169,7 +169,7 @@ static void emulated_push_event(EmulatedState *card, EmulEvent *event)
static void emulated_push_type(EmulatedState *card, uint32_t type)
{
EmulEvent *event = (EmulEvent *)qemu_malloc(sizeof(EmulEvent));
EmulEvent *event = (EmulEvent *)g_malloc(sizeof(EmulEvent));
assert(event);
event->p.gen.type = type;
@@ -178,7 +178,7 @@ static void emulated_push_type(EmulatedState *card, uint32_t type)
static void emulated_push_error(EmulatedState *card, uint64_t code)
{
EmulEvent *event = (EmulEvent *)qemu_malloc(sizeof(EmulEvent));
EmulEvent *event = (EmulEvent *)g_malloc(sizeof(EmulEvent));
assert(event);
event->p.error.type = EMUL_ERROR;
@@ -189,7 +189,7 @@ static void emulated_push_error(EmulatedState *card, uint64_t code)
static void emulated_push_data_type(EmulatedState *card, uint32_t type,
const uint8_t *data, uint32_t len)
{
EmulEvent *event = (EmulEvent *)qemu_malloc(sizeof(EmulEvent) + len);
EmulEvent *event = (EmulEvent *)g_malloc(sizeof(EmulEvent) + len);
assert(event);
event->p.data.type = type;
@@ -249,12 +249,12 @@ static void *handle_apdu_thread(void* arg)
QSIMPLEQ_REMOVE_HEAD(&card->guest_apdu_list, entry);
if (event->p.data.type != EMUL_GUEST_APDU) {
DPRINTF(card, 1, "unexpected message in handle_apdu_thread\n");
qemu_free(event);
g_free(event);
continue;
}
if (card->reader == NULL) {
DPRINTF(card, 1, "reader is NULL\n");
qemu_free(event);
g_free(event);
continue;
}
recv_len = sizeof(recv_data);
@@ -267,7 +267,7 @@ static void *handle_apdu_thread(void* arg)
} else {
emulated_push_error(card, reader_status);
}
qemu_free(event);
g_free(event);
}
qemu_mutex_unlock(&card->vreader_mutex);
}
@@ -401,7 +401,7 @@ static void pipe_read(void *opaque)
DPRINTF(card, 2, "unexpected event\n");
break;
}
qemu_free(event);
g_free(event);
}
QSIMPLEQ_INIT(&card->event_list);
qemu_mutex_unlock(&card->event_list_mutex);

View File

@@ -174,8 +174,6 @@
#define CIRRUS_PNPMMIO_SIZE 0x1000
#define ABS(a) ((signed)(a) > 0 ? a : -a)
#define BLTUNSAFE(s) \
( \
( /* check dst is within bounds */ \
@@ -2372,7 +2370,7 @@ static void unmap_bank(CirrusVGAState *s, unsigned bank)
memory_region_del_subregion(&s->low_mem_container,
s->cirrus_bank[bank]);
memory_region_destroy(s->cirrus_bank[bank]);
qemu_free(s->cirrus_bank[bank]);
g_free(s->cirrus_bank[bank]);
s->cirrus_bank[bank] = NULL;
}
}
@@ -2387,7 +2385,7 @@ static void map_linear_vram_bank(CirrusVGAState *s, unsigned bank)
&& !((s->vga.gr[0x0B] & 0x14) == 0x14)
&& !(s->vga.gr[0x0B] & 0x02)) {
mr = qemu_malloc(sizeof(*mr));
mr = g_malloc(sizeof(*mr));
memory_region_init_alias(mr, names[bank], &s->vga.vram,
s->cirrus_bank_base[bank], 0x8000);
memory_region_add_subregion_overlap(
@@ -2903,7 +2901,7 @@ void isa_cirrus_vga_init(void)
{
CirrusVGAState *s;
s = qemu_mallocz(sizeof(CirrusVGAState));
s = g_malloc0(sizeof(CirrusVGAState));
vga_common_init(&s->vga, VGA_RAM_SIZE);
cirrus_init_common(s, CIRRUS_ID_CLGD5430, 0);

View File

@@ -870,7 +870,7 @@ static void nic_cleanup(VLANClientState *nc)
qemu_del_timer(s->watchdog);
qemu_free_timer(s->watchdog);
qemu_free(s);
g_free(s);
}
static NetClientInfo net_dp83932_info = {
@@ -889,7 +889,7 @@ void dp83932_init(NICInfo *nd, target_phys_addr_t base, int it_shift,
qemu_check_nic_model(nd, "dp83932");
s = qemu_mallocz(sizeof(dp8393xState));
s = g_malloc0(sizeof(dp8393xState));
s->mem_opaque = mem_opaque;
s->memory_rw = memory_rw;

View File

@@ -146,7 +146,7 @@ static int nvram_sysbus_initfn(SysBusDevice *dev)
QEMUFile *file;
int s_io;
s->contents = qemu_mallocz(s->chip_size);
s->contents = g_malloc0(s->chip_size);
s_io = cpu_register_io_memory(nvram_read, nvram_write, s,
DEVICE_NATIVE_ENDIAN);

View File

@@ -1901,7 +1901,7 @@ static int e100_nic_init(PCIDevice *pci_dev)
qemu_register_reset(nic_reset, s);
s->vmstate = qemu_malloc(sizeof(vmstate_eepro100));
s->vmstate = g_malloc(sizeof(vmstate_eepro100));
memcpy(s->vmstate, &vmstate_eepro100, sizeof(vmstate_eepro100));
s->vmstate->name = s->nic->nc.model;
vmstate_register(&pci_dev->qdev, -1, s->vmstate, s);

View File

@@ -310,7 +310,7 @@ eeprom_t *eeprom93xx_new(DeviceState *dev, uint16_t nwords)
addrbits = 6;
}
eeprom = (eeprom_t *)qemu_mallocz(sizeof(*eeprom) + nwords * 2);
eeprom = (eeprom_t *)g_malloc0(sizeof(*eeprom) + nwords * 2);
eeprom->size = nwords;
eeprom->addrbits = addrbits;
/* Output DO is tristate, read results in 1. */
@@ -325,7 +325,7 @@ void eeprom93xx_free(DeviceState *dev, eeprom_t *eeprom)
/* Destroy EEPROM. */
logout("eeprom = 0x%p\n", eeprom);
vmstate_unregister(dev, &vmstate_eeprom, eeprom);
qemu_free(eeprom);
g_free(eeprom);
}
uint16_t *eeprom93xx_data(eeprom_t *eeprom)

View File

@@ -150,7 +150,7 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
i++;
}
if (nsyms) {
syms = qemu_realloc(syms, nsyms * sizeof(*syms));
syms = g_realloc(syms, nsyms * sizeof(*syms));
qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
for (i = 0; i < nsyms - 1; i++) {
@@ -159,7 +159,7 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
}
}
} else {
qemu_free(syms);
g_free(syms);
syms = NULL;
}
@@ -173,19 +173,19 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
goto fail;
/* Commit */
s = qemu_mallocz(sizeof(*s));
s = g_malloc0(sizeof(*s));
s->lookup_symbol = glue(lookup_symbol, SZ);
glue(s->disas_symtab.elf, SZ) = syms;
s->disas_num_syms = nsyms;
s->disas_strtab = str;
s->next = syminfos;
syminfos = s;
qemu_free(shdr_table);
g_free(shdr_table);
return 0;
fail:
qemu_free(syms);
qemu_free(str);
qemu_free(shdr_table);
g_free(syms);
g_free(str);
g_free(shdr_table);
return -1;
}
@@ -238,7 +238,7 @@ static int glue(load_elf, SZ)(const char *name, int fd,
size = ehdr.e_phnum * sizeof(phdr[0]);
lseek(fd, ehdr.e_phoff, SEEK_SET);
phdr = qemu_mallocz(size);
phdr = g_malloc0(size);
if (!phdr)
goto fail;
if (read(fd, phdr, size) != size)
@@ -256,7 +256,7 @@ static int glue(load_elf, SZ)(const char *name, int fd,
if (ph->p_type == PT_LOAD) {
mem_size = ph->p_memsz;
/* XXX: avoid allocating */
data = qemu_mallocz(mem_size);
data = g_malloc0(mem_size);
if (ph->p_filesz > 0) {
if (lseek(fd, ph->p_offset, SEEK_SET) < 0)
goto fail;
@@ -280,18 +280,18 @@ static int glue(load_elf, SZ)(const char *name, int fd,
if ((addr + mem_size) > high)
high = addr + mem_size;
qemu_free(data);
g_free(data);
data = NULL;
}
}
qemu_free(phdr);
g_free(phdr);
if (lowaddr)
*lowaddr = (uint64_t)(elf_sword)low;
if (highaddr)
*highaddr = (uint64_t)(elf_sword)high;
return total_size;
fail:
qemu_free(data);
qemu_free(phdr);
g_free(data);
g_free(phdr);
return -1;
}

View File

@@ -743,12 +743,12 @@ void *etraxfs_dmac_init(target_phys_addr_t base, int nr_channels)
{
struct fs_dma_ctrl *ctrl = NULL;
ctrl = qemu_mallocz(sizeof *ctrl);
ctrl = g_malloc0(sizeof *ctrl);
ctrl->bh = qemu_bh_new(DMA_run, ctrl);
ctrl->nr_channels = nr_channels;
ctrl->channels = qemu_mallocz(sizeof ctrl->channels[0] * nr_channels);
ctrl->channels = g_malloc0(sizeof ctrl->channels[0] * nr_channels);
ctrl->map = cpu_register_io_memory(dma_read, dma_write, ctrl, DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(base, nr_channels * 0x2000, ctrl->map);

View File

@@ -574,7 +574,7 @@ static void eth_cleanup(VLANClientState *nc)
eth->dma_out->client.opaque = NULL;
eth->dma_in->client.opaque = NULL;
eth->dma_in->client.pull = NULL;
qemu_free(eth);
g_free(eth);
}
static NetClientInfo net_etraxfs_info = {

View File

@@ -177,14 +177,14 @@ static void fw_cfg_bootsplash(FWCfgState *s)
/* probing the file */
fp = probe_splashfile(filename, &file_size, &file_type);
if (fp == NULL) {
qemu_free(filename);
g_free(filename);
return;
}
/* loading file data */
if (boot_splash_filedata != NULL) {
qemu_free(boot_splash_filedata);
g_free(boot_splash_filedata);
}
boot_splash_filedata = qemu_malloc(file_size);
boot_splash_filedata = g_malloc(file_size);
boot_splash_filedata_size = file_size;
fseek(fp, 0L, SEEK_SET);
fop_ret = fread(boot_splash_filedata, 1, file_size, fp);
@@ -203,7 +203,7 @@ static void fw_cfg_bootsplash(FWCfgState *s)
fw_cfg_add_file(s, "bootsplash.bmp",
boot_splash_filedata, boot_splash_filedata_size);
}
qemu_free(filename);
g_free(filename);
}
}
@@ -385,7 +385,7 @@ int fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value)
{
uint16_t *copy;
copy = qemu_malloc(sizeof(value));
copy = g_malloc(sizeof(value));
*copy = cpu_to_le16(value);
return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
@@ -394,7 +394,7 @@ int fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value)
{
uint32_t *copy;
copy = qemu_malloc(sizeof(value));
copy = g_malloc(sizeof(value));
*copy = cpu_to_le32(value);
return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
@@ -403,7 +403,7 @@ int fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value)
{
uint64_t *copy;
copy = qemu_malloc(sizeof(value));
copy = g_malloc(sizeof(value));
*copy = cpu_to_le64(value);
return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
@@ -436,7 +436,7 @@ int fw_cfg_add_file(FWCfgState *s, const char *filename, uint8_t *data,
if (!s->files) {
int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS;
s->files = qemu_mallocz(dsize);
s->files = g_malloc0(dsize);
fw_cfg_add_bytes(s, FW_CFG_FILE_DIR, (uint8_t*)s->files, dsize);
}

View File

@@ -590,7 +590,7 @@ int g364fb_mm_init(target_phys_addr_t vram_base,
G364State *s;
int io_ctrl;
s = qemu_mallocz(sizeof(G364State));
s = g_malloc0(sizeof(G364State));
s->vram_size = 8 * 1024 * 1024;
s->vram_offset = qemu_ram_alloc(NULL, "g364fb.vram", s->vram_size);

View File

@@ -345,7 +345,7 @@ static int grlib_gptimer_init(SysBusDevice *dev)
assert(unit->nr_timers > 0);
assert(unit->nr_timers <= GPTIMER_MAX_TIMERS);
unit->timers = qemu_mallocz(sizeof unit->timers[0] * unit->nr_timers);
unit->timers = g_malloc0(sizeof unit->timers[0] * unit->nr_timers);
for (i = 0; i < unit->nr_timers; i++) {
GPTimer *timer = &unit->timers[i];

View File

@@ -345,7 +345,7 @@ static int grlib_irqmp_init(SysBusDevice *dev)
grlib_irqmp_write,
irqmp, DEVICE_NATIVE_ENDIAN);
irqmp->state = qemu_mallocz(sizeof *irqmp->state);
irqmp->state = g_malloc0(sizeof *irqmp->state);
if (irqmp_regs < 0) {
return -1;

View File

@@ -260,7 +260,7 @@ static int gus_initfn (ISADevice *dev)
s->shift = 2;
s->samples = AUD_get_buffer_size_out (s->voice) >> s->shift;
s->mixbuf = qemu_mallocz (s->samples << s->shift);
s->mixbuf = g_malloc0 (s->samples << s->shift);
register_ioport_write (s->port, 1, 1, gus_writeb, s);
register_ioport_write (s->port, 1, 2, gus_writew, s);

View File

@@ -202,7 +202,7 @@ qemu_irq *heathrow_pic_init(MemoryRegion **pmem,
{
HeathrowPICS *s;
s = qemu_mallocz(sizeof(HeathrowPICS));
s = g_malloc0(sizeof(HeathrowPICS));
/* only 1 CPU */
s->irqs = irqs[0];
memory_region_init_io(&s->mem, &heathrow_pic_ops, s,

View File

@@ -526,7 +526,7 @@ qemu_irq *i8259_init(qemu_irq parent_irq)
{
PicState2 *s;
s = qemu_mallocz(sizeof(PicState2));
s = g_malloc0(sizeof(PicState2));
pic_init1(0x20, 0x4d0, &s->pics[0]);
pic_init1(0xa0, 0x4d1, &s->pics[1]);
s->pics[0].elcr_mask = 0xf8;

View File

@@ -1123,7 +1123,7 @@ void ahci_init(AHCIState *s, DeviceState *qdev, int ports)
int i;
s->ports = ports;
s->dev = qemu_mallocz(sizeof(AHCIDevice) * ports);
s->dev = g_malloc0(sizeof(AHCIDevice) * ports);
ahci_reg_init(s);
/* XXX BAR size should be 1k, but that breaks, so bump it to 4k for now */
memory_region_init_io(&s->mem, &ahci_mem_ops, s, "ahci", 0x1000);
@@ -1146,7 +1146,7 @@ void ahci_init(AHCIState *s, DeviceState *qdev, int ports)
void ahci_uninit(AHCIState *s)
{
memory_region_destroy(&s->mem);
qemu_free(s->dev);
g_free(s->dev);
}
void ahci_reset(void *opaque)

View File

@@ -325,7 +325,7 @@ MemoryRegion *pmac_ide_init (DriveInfo **hd_table, qemu_irq irq,
{
MACIOIDEState *d;
d = qemu_mallocz(sizeof(MACIOIDEState));
d = g_malloc0(sizeof(MACIOIDEState));
ide_init2_with_non_qdev_drives(&d->bus, hd_table[0], hd_table[1], irq);
if (dbdma)

View File

@@ -531,7 +531,7 @@ static int dscm1xxxx_detach(void *opaque)
PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv)
{
MicroDriveState *md = (MicroDriveState *) qemu_mallocz(sizeof(MicroDriveState));
MicroDriveState *md = (MicroDriveState *) g_malloc0(sizeof(MicroDriveState));
md->card.state = md;
md->card.attach = dscm1xxxx_attach;
md->card.detach = dscm1xxxx_detach;
@@ -542,7 +542,7 @@ PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv)
qemu_allocate_irqs(md_set_irq, md, 1)[0]);
md->bus.ifs[0].drive_kind = IDE_CFATA;
md->bus.ifs[0].mdata_size = METADATA_SIZE;
md->bus.ifs[0].mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE);
md->bus.ifs[0].mdata_storage = (uint8_t *) g_malloc0(METADATA_SIZE);
vmstate_register(NULL, -1, &vmstate_microdrive, md);

View File

@@ -121,7 +121,7 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2,
qemu_irq irq, int shift,
DriveInfo *hd0, DriveInfo *hd1)
{
MMIOState *s = qemu_mallocz(sizeof(MMIOState));
MMIOState *s = g_malloc0(sizeof(MMIOState));
int mem1, mem2;
ide_init2_with_non_qdev_drives(&s->bus, hd0, hd1, irq);

View File

@@ -148,10 +148,10 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
}
if (!dev->version) {
dev->version = qemu_strdup(s->version);
dev->version = g_strdup(s->version);
}
if (!dev->serial) {
dev->serial = qemu_strdup(s->drive_serial_str);
dev->serial = g_strdup(s->drive_serial_str);
}
add_boot_device_path(dev->conf.bootindex, &dev->qdev,

View File

@@ -467,8 +467,8 @@ static void intel_hda_parse_bdl(IntelHDAState *d, IntelHDAStream *st)
addr = intel_hda_addr(st->bdlp_lbase, st->bdlp_ubase);
st->bentries = st->lvi +1;
qemu_free(st->bpl);
st->bpl = qemu_malloc(sizeof(bpl) * st->bentries);
g_free(st->bpl);
st->bpl = g_malloc(sizeof(bpl) * st->bentries);
for (i = 0; i < st->bentries; i++, addr += 16) {
cpu_physical_memory_read(addr, buf, 16);
st->bpl[i].addr = le64_to_cpu(*(uint64_t *)buf);

View File

@@ -44,8 +44,8 @@ qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n)
struct IRQState *p;
int i;
s = (qemu_irq *)qemu_mallocz(sizeof(qemu_irq) * n);
p = (struct IRQState *)qemu_mallocz(sizeof(struct IRQState) * n);
s = (qemu_irq *)g_malloc0(sizeof(qemu_irq) * n);
p = (struct IRQState *)g_malloc0(sizeof(struct IRQState) * n);
for (i = 0; i < n; i++) {
p->handler = handler;
p->opaque = opaque;
@@ -58,8 +58,8 @@ qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n)
void qemu_free_irqs(qemu_irq *s)
{
qemu_free(s[0]);
qemu_free(s);
g_free(s[0]);
g_free(s);
}
static void qemu_notirq(void *opaque, int line, int level)
@@ -85,7 +85,7 @@ static void qemu_splitirq(void *opaque, int line, int level)
qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2)
{
qemu_irq *s = qemu_mallocz(2 * sizeof(qemu_irq));
qemu_irq *s = g_malloc0(2 * sizeof(qemu_irq));
s[0] = irq1;
s[1] = irq2;
return qemu_allocate_irqs(qemu_splitirq, s, 1)[0];

View File

@@ -74,7 +74,7 @@ void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size)
void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size)
{
MemoryRegion *mr = qemu_malloc(sizeof(*mr));
MemoryRegion *mr = g_malloc(sizeof(*mr));
isa_mmio_setup(mr, size);
memory_region_add_subregion(get_system_memory(), base, mr);

View File

@@ -351,7 +351,7 @@ static void close_guest_eventfds(IVShmemState *s, int posn)
close(s->peers[posn].eventfds[i]);
}
qemu_free(s->peers[posn].eventfds);
g_free(s->peers[posn].eventfds);
s->peers[posn].nb_eventfds = 0;
}
@@ -383,7 +383,7 @@ static void increase_dynamic_storage(IVShmemState *s, int new_min_size) {
s->nb_peers = s->nb_peers * 2;
IVSHMEM_DPRINTF("bumping storage to %d guests\n", s->nb_peers);
s->peers = qemu_realloc(s->peers, s->nb_peers * sizeof(Peer));
s->peers = g_realloc(s->peers, s->nb_peers * sizeof(Peer));
/* zero out new pointers */
for (j = old_nb_alloc; j < s->nb_peers; j++) {
@@ -467,7 +467,7 @@ static void ivshmem_read(void *opaque, const uint8_t * buf, int flags)
if (guest_max_eventfd == 0) {
/* one eventfd per MSI vector */
s->peers[incoming_posn].eventfds = (int *) qemu_malloc(s->vectors *
s->peers[incoming_posn].eventfds = (int *) g_malloc(s->vectors *
sizeof(int));
}
@@ -557,7 +557,7 @@ static void ivshmem_setup_msi(IVShmemState * s) {
}
/* allocate Qemu char devices for receiving interrupts */
s->eventfd_table = qemu_mallocz(s->vectors * sizeof(EventfdEntry));
s->eventfd_table = g_malloc0(s->vectors * sizeof(EventfdEntry));
}
static void ivshmem_save(QEMUFile* f, void *opaque)
@@ -691,12 +691,12 @@ static int pci_ivshmem_init(PCIDevice *dev)
s->vm_id = -1;
/* allocate/initialize space for interrupt handling */
s->peers = qemu_mallocz(s->nb_peers * sizeof(Peer));
s->peers = g_malloc0(s->nb_peers * sizeof(Peer));
pci_register_bar(&s->dev, 2,
PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ivshmem);
s->eventfd_chr = qemu_mallocz(s->vectors * sizeof(CharDriverState *));
s->eventfd_chr = g_malloc0(s->vectors * sizeof(CharDriverState *));
qemu_chr_add_handlers(s->server_chr, ivshmem_can_receive, ivshmem_read,
ivshmem_event, s);

View File

@@ -312,7 +312,7 @@ void jazz_led_init(target_phys_addr_t base)
LedState *s;
int io;
s = qemu_mallocz(sizeof(LedState));
s = g_malloc0(sizeof(LedState));
s->state = REDRAW_SEGMENTS | REDRAW_BACKGROUND;

View File

@@ -122,7 +122,7 @@ static void leon3_generic_hw_init(ram_addr_t ram_size,
cpu_sparc_set_id(env, 0);
/* Reset data */
reset_info = qemu_mallocz(sizeof(ResetData));
reset_info = g_malloc0(sizeof(ResetData));
reset_info->env = env;
qemu_register_reset(main_cpu_reset, reset_info);

View File

@@ -95,7 +95,7 @@ static void lm32_evr_init(ram_addr_t ram_size_not_used,
int timer0_irq = 1;
int timer1_irq = 3;
reset_info = qemu_mallocz(sizeof(ResetInfo));
reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";
@@ -190,7 +190,7 @@ static void lm32_uclinux_init(ram_addr_t ram_size_not_used,
target_phys_addr_t initrd_base = 0x08400000;
size_t initrd_max = 0x01000000;
reset_info = qemu_mallocz(sizeof(ResetInfo));
reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";

View File

@@ -57,8 +57,8 @@ static inline HWSetup *hwsetup_init(void)
{
HWSetup *hw;
hw = qemu_malloc(sizeof(HWSetup));
hw->data = qemu_mallocz(TARGET_PAGE_SIZE);
hw = g_malloc(sizeof(HWSetup));
hw->data = g_malloc0(TARGET_PAGE_SIZE);
hw->ptr = hw->data;
return hw;
@@ -66,8 +66,8 @@ static inline HWSetup *hwsetup_init(void)
static inline void hwsetup_free(HWSetup *hw)
{
qemu_free(hw->data);
qemu_free(hw);
g_free(hw->data);
g_free(hw);
}
static inline void hwsetup_create_rom(HWSetup *hw,

View File

@@ -91,11 +91,11 @@ int read_targphys(const char *name,
uint8_t *buf;
size_t did;
buf = qemu_malloc(nbytes);
buf = g_malloc(nbytes);
did = read(fd, buf, nbytes);
if (did > 0)
rom_add_blob_fixed("read", buf, did, dst_addr);
qemu_free(buf);
g_free(buf);
return did;
}
@@ -234,9 +234,9 @@ static void *load_at(int fd, int offset, int size)
void *ptr;
if (lseek(fd, offset, SEEK_SET) < 0)
return NULL;
ptr = qemu_malloc(size);
ptr = g_malloc(size);
if (read(fd, ptr, size) != size) {
qemu_free(ptr);
g_free(ptr);
return NULL;
}
return ptr;
@@ -351,14 +351,14 @@ static void *zalloc(void *x, unsigned items, unsigned size)
size *= items;
size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1);
p = qemu_malloc(size);
p = g_malloc(size);
return (p);
}
static void zfree(void *x, void *addr)
{
qemu_free(addr);
g_free(addr);
}
@@ -476,7 +476,7 @@ int load_uimage(const char *filename, target_phys_addr_t *ep,
}
*ep = hdr->ih_ep;
data = qemu_malloc(hdr->ih_size);
data = g_malloc(hdr->ih_size);
if (read(fd, data, hdr->ih_size) != hdr->ih_size) {
fprintf(stderr, "Error reading file\n");
@@ -490,10 +490,10 @@ int load_uimage(const char *filename, target_phys_addr_t *ep,
compressed_data = data;
max_bytes = UBOOT_MAX_GUNZIP_BYTES;
data = qemu_malloc(max_bytes);
data = g_malloc(max_bytes);
bytes = gunzip(data, max_bytes, compressed_data, hdr->ih_size);
qemu_free(compressed_data);
g_free(compressed_data);
if (bytes < 0) {
fprintf(stderr, "Unable to decompress gzipped image!\n");
goto out;
@@ -510,7 +510,7 @@ int load_uimage(const char *filename, target_phys_addr_t *ep,
out:
if (data)
qemu_free(data);
g_free(data);
close(fd);
return ret;
}
@@ -564,11 +564,11 @@ int rom_add_file(const char *file, const char *fw_dir,
int rc, fd = -1;
char devpath[100];
rom = qemu_mallocz(sizeof(*rom));
rom->name = qemu_strdup(file);
rom = g_malloc0(sizeof(*rom));
rom->name = g_strdup(file);
rom->path = qemu_find_file(QEMU_FILE_TYPE_BIOS, rom->name);
if (rom->path == NULL) {
rom->path = qemu_strdup(file);
rom->path = g_strdup(file);
}
fd = open(rom->path, O_RDONLY | O_BINARY);
@@ -579,12 +579,12 @@ int rom_add_file(const char *file, const char *fw_dir,
}
if (fw_dir) {
rom->fw_dir = qemu_strdup(fw_dir);
rom->fw_file = qemu_strdup(file);
rom->fw_dir = g_strdup(fw_dir);
rom->fw_file = g_strdup(file);
}
rom->addr = addr;
rom->romsize = lseek(fd, 0, SEEK_END);
rom->data = qemu_mallocz(rom->romsize);
rom->data = g_malloc0(rom->romsize);
lseek(fd, 0, SEEK_SET);
rc = read(fd, rom->data, rom->romsize);
if (rc != rom->romsize) {
@@ -618,10 +618,10 @@ int rom_add_file(const char *file, const char *fw_dir,
err:
if (fd != -1)
close(fd);
qemu_free(rom->data);
qemu_free(rom->path);
qemu_free(rom->name);
qemu_free(rom);
g_free(rom->data);
g_free(rom->path);
g_free(rom->name);
g_free(rom);
return -1;
}
@@ -630,11 +630,11 @@ int rom_add_blob(const char *name, const void *blob, size_t len,
{
Rom *rom;
rom = qemu_mallocz(sizeof(*rom));
rom->name = qemu_strdup(name);
rom = g_malloc0(sizeof(*rom));
rom->name = g_strdup(name);
rom->addr = addr;
rom->romsize = len;
rom->data = qemu_mallocz(rom->romsize);
rom->data = g_malloc0(rom->romsize);
memcpy(rom->data, blob, len);
rom_insert(rom);
return 0;
@@ -664,7 +664,7 @@ static void rom_reset(void *unused)
cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize);
if (rom->isrom) {
/* rom needs to be written only once */
qemu_free(rom->data);
g_free(rom->data);
rom->data = NULL;
}
}

View File

@@ -353,10 +353,10 @@ static void lsi_soft_reset(LSIState *s)
while (!QTAILQ_EMPTY(&s->queue)) {
p = QTAILQ_FIRST(&s->queue);
QTAILQ_REMOVE(&s->queue, p, next);
qemu_free(p);
g_free(p);
}
if (s->current) {
qemu_free(s->current);
g_free(s->current);
s->current = NULL;
}
}
@@ -664,7 +664,7 @@ static void lsi_request_cancelled(SCSIRequest *req)
if (s->current && req == s->current->req) {
scsi_req_unref(req);
qemu_free(s->current);
g_free(s->current);
s->current = NULL;
return;
}
@@ -672,7 +672,7 @@ static void lsi_request_cancelled(SCSIRequest *req)
if (p) {
QTAILQ_REMOVE(&s->queue, p, next);
scsi_req_unref(req);
qemu_free(p);
g_free(p);
}
}
@@ -723,7 +723,7 @@ static void lsi_command_complete(SCSIRequest *req, uint32_t status)
if (s->current && req == s->current->req) {
scsi_req_unref(s->current->req);
qemu_free(s->current);
g_free(s->current);
s->current = NULL;
}
lsi_resume_script(s);
@@ -779,7 +779,7 @@ static void lsi_do_command(LSIState *s)
}
assert(s->current == NULL);
s->current = qemu_mallocz(sizeof(lsi_request));
s->current = g_malloc0(sizeof(lsi_request));
s->current->tag = s->select_tag;
s->current->req = scsi_req_new(dev, s->current->tag, s->current_lun, buf,
s->current);

View File

@@ -679,7 +679,7 @@ M48t59State *m48t59_init_isa(uint32_t io_base, uint16_t size, int type)
static void m48t59_init_common(M48t59State *s)
{
s->buffer = qemu_mallocz(s->size);
s->buffer = g_malloc0(s->size);
if (s->type == 59) {
s->alrm_timer = qemu_new_timer_ns(vm_clock, &alarm_cb, s);
s->wd_timer = qemu_new_timer_ns(vm_clock, &watchdog_cb, s);

View File

@@ -846,7 +846,7 @@ void* DBDMA_init (MemoryRegion **dbdma_mem)
{
DBDMAState *s;
s = qemu_mallocz(sizeof(DBDMAState));
s = g_malloc0(sizeof(DBDMAState));
memory_region_init_io(&s->mem, &dbdma_ops, s, "dbdma", 0x1000);
*dbdma_mem = &s->mem;

View File

@@ -121,8 +121,8 @@ MacIONVRAMState *macio_nvram_init (target_phys_addr_t size,
{
MacIONVRAMState *s;
s = qemu_mallocz(sizeof(MacIONVRAMState));
s->data = qemu_mallocz(size);
s = g_malloc0(sizeof(MacIONVRAMState));
s->data = g_malloc0(size);
s->size = size;
s->it_shift = it_shift;

View File

@@ -132,7 +132,7 @@ static m5206_timer_state *m5206_timer_init(qemu_irq irq)
m5206_timer_state *s;
QEMUBH *bh;
s = (m5206_timer_state *)qemu_mallocz(sizeof(m5206_timer_state));
s = (m5206_timer_state *)g_malloc0(sizeof(m5206_timer_state));
bh = qemu_bh_new(m5206_timer_trigger, s);
s->timer = ptimer_init(bh);
s->irq = irq;
@@ -523,7 +523,7 @@ qemu_irq *mcf5206_init(uint32_t base, CPUState *env)
qemu_irq *pic;
int iomemtype;
s = (m5206_mbar_state *)qemu_mallocz(sizeof(m5206_mbar_state));
s = (m5206_mbar_state *)g_malloc0(sizeof(m5206_mbar_state));
iomemtype = cpu_register_io_memory(m5206_mbar_readfn,
m5206_mbar_writefn, s,
DEVICE_NATIVE_ENDIAN);

View File

@@ -185,7 +185,7 @@ static void mcf5208_sys_init(qemu_irq *pic)
cpu_register_physical_memory(0xfc0a8000, 0x00004000, iomemtype);
/* Timers. */
for (i = 0; i < 2; i++) {
s = (m5208_timer_state *)qemu_mallocz(sizeof(m5208_timer_state));
s = (m5208_timer_state *)g_malloc0(sizeof(m5208_timer_state));
bh = qemu_bh_new(m5208_timer_trigger, s);
s->timer = ptimer_init(bh);
iomemtype = cpu_register_io_memory(m5208_timer_readfn,

View File

@@ -447,7 +447,7 @@ static void mcf_fec_cleanup(VLANClientState *nc)
cpu_unregister_io_memory(s->mmio_index);
qemu_free(s);
g_free(s);
}
static NetClientInfo net_mcf_fec_info = {
@@ -464,7 +464,7 @@ void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq)
qemu_check_nic_model(nd, "mcf_fec");
s = (mcf_fec_state *)qemu_mallocz(sizeof(mcf_fec_state));
s = (mcf_fec_state *)g_malloc0(sizeof(mcf_fec_state));
s->irq = irq;
s->mmio_index = cpu_register_io_memory(mcf_fec_readfn,
mcf_fec_writefn, s,

View File

@@ -144,7 +144,7 @@ qemu_irq *mcf_intc_init(target_phys_addr_t base, CPUState *env)
mcf_intc_state *s;
int iomemtype;
s = qemu_mallocz(sizeof(mcf_intc_state));
s = g_malloc0(sizeof(mcf_intc_state));
s->env = env;
mcf_intc_reset(s);

View File

@@ -272,7 +272,7 @@ void *mcf_uart_init(qemu_irq irq, CharDriverState *chr)
{
mcf_uart_state *s;
s = qemu_mallocz(sizeof(mcf_uart_state));
s = g_malloc0(sizeof(mcf_uart_state));
s->chr = chr;
s->irq = irq;
if (chr) {

View File

@@ -99,7 +99,7 @@ milkymist_init(ram_addr_t ram_size_not_used,
target_phys_addr_t cmdline_base = sdram_base + 0x1000000;
size_t initrd_max = sdram_size - 0x1002000;
reset_info = qemu_mallocz(sizeof(ResetInfo));
reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";

View File

@@ -140,7 +140,7 @@ static int64_t load_kernel (CPUState *env)
/* Setup prom parameters. */
prom_size = ENVP_NB_ENTRIES * (sizeof(int32_t) + ENVP_ENTRY_SIZE);
prom_buf = qemu_malloc(prom_size);
prom_buf = g_malloc(prom_size);
prom_set(prom_buf, index++, "%s", loaderparams.kernel_filename);
if (initrd_size > 0) {
@@ -313,7 +313,7 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,
if (filename) {
bios_size = load_image_targphys(filename, 0x1fc00000LL,
BIOS_SIZE);
qemu_free(filename);
g_free(filename);
} else {
bios_size = -1;
}

View File

@@ -158,7 +158,7 @@ void mips_jazz_init (ram_addr_t ram_size,
if (filename) {
bios_size = load_image_targphys(filename, 0xfff00000LL,
MAGNUM_BIOS_SIZE);
qemu_free(filename);
g_free(filename);
} else {
bios_size = -1;
}
@@ -207,7 +207,7 @@ void mips_jazz_init (ram_addr_t ram_size,
for (n = 0; n < nb_nics; n++) {
nd = &nd_table[n];
if (!nd->model)
nd->model = qemu_strdup("dp83932");
nd->model = g_strdup("dp83932");
if (strcmp(nd->model, "dp83932") == 0) {
dp83932_init(nd, 0x80001000, 2, rc4030[4],
rc4030_opaque, rc4030_dma_memory_rw);

View File

@@ -433,7 +433,7 @@ static MaltaFPGAState *malta_fpga_init(target_phys_addr_t base, qemu_irq uart_ir
MaltaFPGAState *s;
int malta;
s = (MaltaFPGAState *)qemu_mallocz(sizeof(MaltaFPGAState));
s = (MaltaFPGAState *)g_malloc0(sizeof(MaltaFPGAState));
malta = cpu_register_io_memory(malta_fpga_read,
malta_fpga_write, s,
@@ -709,7 +709,7 @@ static int64_t load_kernel (void)
/* Setup prom parameters. */
prom_size = ENVP_NB_ENTRIES * (sizeof(int32_t) + ENVP_ENTRY_SIZE);
prom_buf = qemu_malloc(prom_size);
prom_buf = g_malloc(prom_size);
prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_filename);
if (initrd_size > 0) {
@@ -863,7 +863,7 @@ void mips_malta_init (ram_addr_t ram_size,
if (filename) {
bios_size = load_image_targphys(filename, 0x1fc00000LL,
BIOS_SIZE);
qemu_free(filename);
g_free(filename);
} else {
bios_size = -1;
}

View File

@@ -138,7 +138,7 @@ mips_mipssim_init (ram_addr_t ram_size,
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
reset_info = qemu_mallocz(sizeof(ResetData));
reset_info = g_malloc0(sizeof(ResetData));
reset_info->env = env;
reset_info->vector = env->active_tc.PC;
qemu_register_reset(main_cpu_reset, reset_info);
@@ -158,7 +158,7 @@ mips_mipssim_init (ram_addr_t ram_size,
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, 0x1fc00000LL, BIOS_SIZE);
qemu_free(filename);
g_free(filename);
} else {
bios_size = -1;
}

View File

@@ -126,7 +126,7 @@ static int64_t load_kernel(void)
/* Store command line. */
params_size = 264;
params_buf = qemu_malloc(params_size);
params_buf = g_malloc(params_size);
params_buf[0] = tswap32(ram_size);
params_buf[1] = tswap32(0x12345678);
@@ -186,7 +186,7 @@ void mips_r4k_init (ram_addr_t ram_size,
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
reset_info = qemu_mallocz(sizeof(ResetData));
reset_info = g_malloc0(sizeof(ResetData));
reset_info->env = env;
reset_info->vector = env->active_tc.PC;
qemu_register_reset(main_cpu_reset, reset_info);
@@ -248,7 +248,7 @@ void mips_r4k_init (ram_addr_t ram_size,
bios_name);
}
if (filename) {
qemu_free(filename);
g_free(filename);
}
if (kernel_filename) {

View File

@@ -228,7 +228,7 @@ static void mipsnet_cleanup(VLANClientState *nc)
isa_unassign_ioport(s->io_base, 36);
qemu_free(s);
g_free(s);
}
static NetClientInfo net_mipsnet_info = {
@@ -245,7 +245,7 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd)
qemu_check_nic_model(nd, "mipsnet");
s = qemu_mallocz(sizeof(MIPSnetState));
s = g_malloc0(sizeof(MIPSnetState));
register_ioport_write(base, 36, 1, mipsnet_ioport_write, s);
register_ioport_read(base, 36, 1, mipsnet_ioport_read, s);

View File

@@ -219,10 +219,10 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries,
if (nentries > MSIX_MAX_ENTRIES)
return -EINVAL;
dev->msix_entry_used = qemu_mallocz(MSIX_MAX_ENTRIES *
dev->msix_entry_used = g_malloc0(MSIX_MAX_ENTRIES *
sizeof *dev->msix_entry_used);
dev->msix_table_page = qemu_mallocz(MSIX_PAGE_SIZE);
dev->msix_table_page = g_malloc0(MSIX_PAGE_SIZE);
msix_mask_all(dev, nentries);
memory_region_init_io(&dev->msix_mmio, &msix_mmio_ops, dev,
@@ -240,9 +240,9 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries,
err_config:
dev->msix_entries_nr = 0;
memory_region_destroy(&dev->msix_mmio);
qemu_free(dev->msix_table_page);
g_free(dev->msix_table_page);
dev->msix_table_page = NULL;
qemu_free(dev->msix_entry_used);
g_free(dev->msix_entry_used);
dev->msix_entry_used = NULL;
return ret;
}
@@ -268,9 +268,9 @@ int msix_uninit(PCIDevice *dev, MemoryRegion *bar)
dev->msix_entries_nr = 0;
memory_region_del_subregion(bar, &dev->msix_mmio);
memory_region_destroy(&dev->msix_mmio);
qemu_free(dev->msix_table_page);
g_free(dev->msix_table_page);
dev->msix_table_page = NULL;
qemu_free(dev->msix_entry_used);
g_free(dev->msix_entry_used);
dev->msix_entry_used = NULL;
dev->cap_present &= ~QEMU_PCI_CAP_MSIX;
return 0;

View File

@@ -61,14 +61,14 @@ static int msmouse_chr_write (struct CharDriverState *s, const uint8_t *buf, int
static void msmouse_chr_close (struct CharDriverState *chr)
{
qemu_free (chr);
g_free (chr);
}
int qemu_chr_open_msmouse(QemuOpts *opts, CharDriverState **_chr)
{
CharDriverState *chr;
chr = qemu_mallocz(sizeof(CharDriverState));
chr = g_malloc0(sizeof(CharDriverState));
chr->chr_write = msmouse_chr_write;
chr->chr_close = msmouse_chr_close;

View File

@@ -187,7 +187,7 @@ int load_multiboot(void *fw_cfg,
mb_kernel_size = elf_high - elf_low;
mh_entry_addr = elf_entry;
mbs.mb_buf = qemu_malloc(mb_kernel_size);
mbs.mb_buf = g_malloc(mb_kernel_size);
if (rom_copy(mbs.mb_buf, mh_load_addr, mb_kernel_size) != mb_kernel_size) {
fprintf(stderr, "Error while fetching elf kernel from rom\n");
exit(1);
@@ -220,7 +220,7 @@ int load_multiboot(void *fw_cfg,
mb_debug("qemu: loading multiboot kernel (%#x bytes) at %#x\n",
mb_load_size, mh_load_addr);
mbs.mb_buf = qemu_malloc(mb_kernel_size);
mbs.mb_buf = g_malloc(mb_kernel_size);
fseek(f, mb_kernel_text_offset, SEEK_SET);
if (fread(mbs.mb_buf, 1, mb_load_size, f) != mb_load_size) {
fprintf(stderr, "fread() failed\n");
@@ -252,7 +252,7 @@ int load_multiboot(void *fw_cfg,
mbs.mb_buf_size = TARGET_PAGE_ALIGN(mbs.mb_buf_size);
/* enlarge mb_buf to hold cmdlines and mb-info structs */
mbs.mb_buf = qemu_realloc(mbs.mb_buf, mbs.mb_buf_size);
mbs.mb_buf = g_realloc(mbs.mb_buf, mbs.mb_buf_size);
mbs.offset_cmdlines = mbs.offset_mbinfo + mbs.mb_mods_avail * MB_MOD_SIZE;
if (initrd_filename) {
@@ -281,7 +281,7 @@ int load_multiboot(void *fw_cfg,
}
mbs.mb_buf_size = TARGET_PAGE_ALIGN(mb_mod_length + mbs.mb_buf_size);
mbs.mb_buf = qemu_realloc(mbs.mb_buf, mbs.mb_buf_size);
mbs.mb_buf = g_realloc(mbs.mb_buf, mbs.mb_buf_size);
load_image(initrd_filename, (unsigned char *)mbs.mb_buf + offs);
mb_add_mod(&mbs, mbs.mb_buf_phys + offs,
@@ -320,7 +320,7 @@ int load_multiboot(void *fw_cfg,
mb_debug(" mb_mods_count = %d\n", mbs.mb_mods_count);
/* save bootinfo off the stack */
mb_bootinfo_data = qemu_malloc(sizeof(bootinfo));
mb_bootinfo_data = g_malloc(sizeof(bootinfo));
memcpy(mb_bootinfo_data, bootinfo, sizeof(bootinfo));
/* Pass variables to option rom */

View File

@@ -399,7 +399,7 @@ static int nand_device_init(SysBusDevice *dev)
pagesize += 1 << s->page_shift;
}
if (pagesize) {
s->storage = (uint8_t *) memset(qemu_malloc(s->pages * pagesize),
s->storage = (uint8_t *) memset(g_malloc(s->pages * pagesize),
0xff, s->pages * pagesize);
}
/* Give s->ioaddr a sane value in case we save state before it is used. */

View File

@@ -654,7 +654,7 @@ static uint32_t mipid_txrx(void *opaque, uint32_t cmd, int len)
static void *mipid_init(void)
{
struct mipid_s *s = (struct mipid_s *) qemu_mallocz(sizeof(*s));
struct mipid_s *s = (struct mipid_s *) g_malloc0(sizeof(*s));
s->id = 0x838f03;
mipid_reset(s);
@@ -710,10 +710,10 @@ static void n800_dss_init(struct rfbi_chip_s *chip)
chip->write(chip->opaque, 1, 0x01); /* Input Data Format */
chip->write(chip->opaque, 1, 0x01); /* Data Source Select */
fb_blank = memset(qemu_malloc(800 * 480 * 2), 0xff, 800 * 480 * 2);
fb_blank = memset(g_malloc(800 * 480 * 2), 0xff, 800 * 480 * 2);
/* Display Memory Data Port */
chip->block(chip->opaque, 1, fb_blank, 800 * 480 * 2, 800);
qemu_free(fb_blank);
g_free(fb_blank);
}
static void n8x0_dss_setup(struct n800_s *s)
@@ -1270,7 +1270,7 @@ static void n8x0_init(ram_addr_t ram_size, const char *boot_device,
const char *kernel_cmdline, const char *initrd_filename,
const char *cpu_model, struct arm_boot_info *binfo, int model)
{
struct n800_s *s = (struct n800_s *) qemu_mallocz(sizeof(*s));
struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s));
int sdram_size = binfo->ram_size;
DisplayState *ds;

View File

@@ -1107,7 +1107,7 @@ inline static int debug_register_io_memory(CPUReadMemoryFunc * const *mem_read,
CPUWriteMemoryFunc * const *mem_write,
void *opaque)
{
struct io_fn *s = qemu_malloc(sizeof(struct io_fn));
struct io_fn *s = g_malloc(sizeof(struct io_fn));
s->mem_read = mem_read;
s->mem_write = mem_write;

View File

@@ -255,7 +255,7 @@ static struct omap_mpu_timer_s *omap_mpu_timer_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *)
qemu_mallocz(sizeof(struct omap_mpu_timer_s));
g_malloc0(sizeof(struct omap_mpu_timer_s));
s->irq = irq;
s->clk = clk;
@@ -379,7 +379,7 @@ static struct omap_watchdog_timer_s *omap_wd_timer_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *)
qemu_mallocz(sizeof(struct omap_watchdog_timer_s));
g_malloc0(sizeof(struct omap_watchdog_timer_s));
s->timer.irq = irq;
s->timer.clk = clk;
@@ -481,7 +481,7 @@ static struct omap_32khz_timer_s *omap_os_timer_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *)
qemu_mallocz(sizeof(struct omap_32khz_timer_s));
g_malloc0(sizeof(struct omap_32khz_timer_s));
s->timer.irq = irq;
s->timer.clk = clk;
@@ -1188,7 +1188,7 @@ static struct omap_tipb_bridge_s *omap_tipb_bridge_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *)
qemu_mallocz(sizeof(struct omap_tipb_bridge_s));
g_malloc0(sizeof(struct omap_tipb_bridge_s));
s->abort = abort_irq;
omap_tipb_bridge_reset(s);
@@ -2025,7 +2025,7 @@ struct omap_mpuio_s *omap_mpuio_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_mpuio_s *s = (struct omap_mpuio_s *)
qemu_mallocz(sizeof(struct omap_mpuio_s));
g_malloc0(sizeof(struct omap_mpuio_s));
s->irq = gpio_int;
s->kbd_irq = kbd_int;
@@ -2211,7 +2211,7 @@ struct omap_uwire_s *omap_uwire_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_uwire_s *s = (struct omap_uwire_s *)
qemu_mallocz(sizeof(struct omap_uwire_s));
g_malloc0(sizeof(struct omap_uwire_s));
s->txirq = irq[0];
s->rxirq = irq[1];
@@ -2819,7 +2819,7 @@ static struct omap_rtc_s *omap_rtc_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_rtc_s *s = (struct omap_rtc_s *)
qemu_mallocz(sizeof(struct omap_rtc_s));
g_malloc0(sizeof(struct omap_rtc_s));
s->irq = irq[0];
s->alarm = irq[1];
@@ -3339,7 +3339,7 @@ struct omap_mcbsp_s *omap_mcbsp_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *)
qemu_mallocz(sizeof(struct omap_mcbsp_s));
g_malloc0(sizeof(struct omap_mcbsp_s));
s->txirq = irq[0];
s->rxirq = irq[1];
@@ -3515,7 +3515,7 @@ static struct omap_lpg_s *omap_lpg_init(target_phys_addr_t base, omap_clk clk)
{
int iomemtype;
struct omap_lpg_s *s = (struct omap_lpg_s *)
qemu_mallocz(sizeof(struct omap_lpg_s));
g_malloc0(sizeof(struct omap_lpg_s));
s->tm = qemu_new_timer_ms(rt_clock, omap_lpg_tick, s);
@@ -3711,7 +3711,7 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size,
{
int i;
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *)
qemu_mallocz(sizeof(struct omap_mpu_state_s));
g_malloc0(sizeof(struct omap_mpu_state_s));
ram_addr_t imif_base, emiff_base;
qemu_irq *cpu_irq;
qemu_irq dma_irqs[6];

View File

@@ -591,7 +591,7 @@ static struct omap_eac_s *omap_eac_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_eac_s *s = (struct omap_eac_s *)
qemu_mallocz(sizeof(struct omap_eac_s));
g_malloc0(sizeof(struct omap_eac_s));
s->irq = irq;
s->codec.rxdrq = *drq ++;
@@ -777,7 +777,7 @@ static struct omap_sti_s *omap_sti_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_sti_s *s = (struct omap_sti_s *)
qemu_mallocz(sizeof(struct omap_sti_s));
g_malloc0(sizeof(struct omap_sti_s));
s->irq = irq;
omap_sti_reset(s);
@@ -1790,7 +1790,7 @@ static struct omap_prcm_s *omap_prcm_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_prcm_s *s = (struct omap_prcm_s *)
qemu_mallocz(sizeof(struct omap_prcm_s));
g_malloc0(sizeof(struct omap_prcm_s));
s->irq[0] = mpu_int;
s->irq[1] = dsp_int;
@@ -2163,7 +2163,7 @@ static struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_sysctl_s *s = (struct omap_sysctl_s *)
qemu_mallocz(sizeof(struct omap_sysctl_s));
g_malloc0(sizeof(struct omap_sysctl_s));
s->mpu = mpu;
omap_sysctl_reset(s);
@@ -2228,7 +2228,7 @@ struct omap_mpu_state_s *omap2420_mpu_init(unsigned long sdram_size,
const char *core)
{
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *)
qemu_mallocz(sizeof(struct omap_mpu_state_s));
g_malloc0(sizeof(struct omap_mpu_state_s));
ram_addr_t sram_base, q2_base;
qemu_irq *cpu_irq;
qemu_irq dma_irqs[4];

View File

@@ -1239,7 +1239,7 @@ void omap_clk_init(struct omap_mpu_state_s *mpu)
for (i = onchip_clks, count = 0; *i; i ++)
if ((*i)->flags & flag)
count ++;
mpu->clks = (struct clk *) qemu_mallocz(sizeof(struct clk) * (count + 1));
mpu->clks = (struct clk *) g_malloc0(sizeof(struct clk) * (count + 1));
for (i = onchip_clks, j = mpu->clks; *i; i ++)
if ((*i)->flags & flag) {
memcpy(j, *i, sizeof(struct clk));

View File

@@ -1620,7 +1620,7 @@ struct soc_dma_s *omap_dma_init(target_phys_addr_t base, qemu_irq *irqs,
{
int iomemtype, num_irqs, memsize, i;
struct omap_dma_s *s = (struct omap_dma_s *)
qemu_mallocz(sizeof(struct omap_dma_s));
g_malloc0(sizeof(struct omap_dma_s));
if (model <= omap_dma_3_1) {
num_irqs = 6;
@@ -2039,7 +2039,7 @@ struct soc_dma_s *omap_dma4_init(target_phys_addr_t base, qemu_irq *irqs,
{
int iomemtype, i;
struct omap_dma_s *s = (struct omap_dma_s *)
qemu_mallocz(sizeof(struct omap_dma_s));
g_malloc0(sizeof(struct omap_dma_s));
s->model = omap_dma_4;
s->chans = chans;

View File

@@ -627,7 +627,7 @@ static void omap_rfbi_transfer_start(struct omap_dss_s *s)
}
if (!data) {
if (len > bounce_len) {
bounce_buffer = qemu_realloc(bounce_buffer, len);
bounce_buffer = g_realloc(bounce_buffer, len);
}
data = bounce_buffer;
cpu_physical_memory_read(data_addr, data, len);
@@ -1030,7 +1030,7 @@ struct omap_dss_s *omap_dss_init(struct omap_target_agent_s *ta,
{
int iomemtype[5];
struct omap_dss_s *s = (struct omap_dss_s *)
qemu_mallocz(sizeof(struct omap_dss_s));
g_malloc0(sizeof(struct omap_dss_s));
s->irq = irq;
s->drq = drq;

View File

@@ -696,8 +696,8 @@ static int omap2_gpio_init(SysBusDevice *dev)
} else {
s->modulecount = 6;
}
s->modules = qemu_mallocz(s->modulecount * sizeof(struct omap2_gpio_s));
s->handler = qemu_mallocz(s->modulecount * 32 * sizeof(qemu_irq));
s->modules = g_malloc0(s->modulecount * sizeof(struct omap2_gpio_s));
s->handler = g_malloc0(s->modulecount * 32 * sizeof(qemu_irq));
qdev_init_gpio_in(&dev->qdev, omap2_gpio_set, s->modulecount * 32);
qdev_init_gpio_out(&dev->qdev, s->handler, s->modulecount * 32);
for (i = 0; i < s->modulecount; i++) {

View File

@@ -385,7 +385,7 @@ struct omap_gpmc_s *omap_gpmc_init(target_phys_addr_t base, qemu_irq irq)
{
int iomemtype;
struct omap_gpmc_s *s = (struct omap_gpmc_s *)
qemu_mallocz(sizeof(struct omap_gpmc_s));
g_malloc0(sizeof(struct omap_gpmc_s));
omap_gpmc_reset(s);

View File

@@ -465,7 +465,7 @@ struct omap_gp_timer_s *omap_gp_timer_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_gp_timer_s *s = (struct omap_gp_timer_s *)
qemu_mallocz(sizeof(struct omap_gp_timer_s));
g_malloc0(sizeof(struct omap_gp_timer_s));
s->ta = ta;
s->irq = irq;

View File

@@ -426,7 +426,7 @@ struct omap_i2c_s *omap_i2c_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_i2c_s *s = (struct omap_i2c_s *)
qemu_mallocz(sizeof(struct omap_i2c_s));
g_malloc0(sizeof(struct omap_i2c_s));
/* TODO: set a value greater or equal to real hardware */
s->revision = 0x11;
@@ -448,7 +448,7 @@ struct omap_i2c_s *omap2_i2c_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_i2c_s *s = (struct omap_i2c_s *)
qemu_mallocz(sizeof(struct omap_i2c_s));
g_malloc0(sizeof(struct omap_i2c_s));
s->revision = 0x34;
s->irq = irq;

View File

@@ -358,7 +358,7 @@ struct omap_intr_handler_s *omap_inth_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_intr_handler_s *s = (struct omap_intr_handler_s *)
qemu_mallocz(sizeof(struct omap_intr_handler_s) +
g_malloc0(sizeof(struct omap_intr_handler_s) +
sizeof(struct omap_intr_handler_bank_s) * nbanks);
s->parent_intr[0] = parent_irq;
@@ -577,7 +577,7 @@ struct omap_intr_handler_s *omap2_inth_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_intr_handler_s *s = (struct omap_intr_handler_s *)
qemu_mallocz(sizeof(struct omap_intr_handler_s) +
g_malloc0(sizeof(struct omap_intr_handler_s) +
sizeof(struct omap_intr_handler_bank_s) * nbanks);
s->parent_intr[0] = parent_irq;

View File

@@ -120,7 +120,7 @@ struct omap_l4_s {
struct omap_l4_s *omap_l4_init(target_phys_addr_t base, int ta_num)
{
struct omap_l4_s *bus = qemu_mallocz(
struct omap_l4_s *bus = g_malloc0(
sizeof(*bus) + ta_num * sizeof(*bus->ta));
bus->ta_num = ta_num;
@@ -128,19 +128,19 @@ struct omap_l4_s *omap_l4_init(target_phys_addr_t base, int ta_num)
#ifdef L4_MUX_HACK
omap_l4_io_entries = 1;
omap_l4_io_entry = qemu_mallocz(125 * sizeof(*omap_l4_io_entry));
omap_l4_io_entry = g_malloc0(125 * sizeof(*omap_l4_io_entry));
omap_cpu_io_entry =
cpu_register_io_memory(omap_l4_io_readfn,
omap_l4_io_writefn, bus, DEVICE_NATIVE_ENDIAN);
# define L4_PAGES (0xb4000 / TARGET_PAGE_SIZE)
omap_l4_io_readb_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
omap_l4_io_readh_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
omap_l4_io_readw_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
omap_l4_io_writeb_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
omap_l4_io_writeh_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
omap_l4_io_writew_fn = qemu_mallocz(sizeof(void *) * L4_PAGES);
omap_l4_io_opaque = qemu_mallocz(sizeof(void *) * L4_PAGES);
omap_l4_io_readb_fn = g_malloc0(sizeof(void *) * L4_PAGES);
omap_l4_io_readh_fn = g_malloc0(sizeof(void *) * L4_PAGES);
omap_l4_io_readw_fn = g_malloc0(sizeof(void *) * L4_PAGES);
omap_l4_io_writeb_fn = g_malloc0(sizeof(void *) * L4_PAGES);
omap_l4_io_writeh_fn = g_malloc0(sizeof(void *) * L4_PAGES);
omap_l4_io_writew_fn = g_malloc0(sizeof(void *) * L4_PAGES);
omap_l4_io_opaque = g_malloc0(sizeof(void *) * L4_PAGES);
#endif
return bus;

View File

@@ -441,7 +441,7 @@ struct omap_lcd_panel_s *omap_lcdc_init(target_phys_addr_t base, qemu_irq irq,
{
int iomemtype;
struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *)
qemu_mallocz(sizeof(struct omap_lcd_panel_s));
g_malloc0(sizeof(struct omap_lcd_panel_s));
s->irq = irq;
s->dma = dma;

View File

@@ -576,7 +576,7 @@ struct omap_mmc_s *omap_mmc_init(target_phys_addr_t base,
{
int iomemtype;
struct omap_mmc_s *s = (struct omap_mmc_s *)
qemu_mallocz(sizeof(struct omap_mmc_s));
g_malloc0(sizeof(struct omap_mmc_s));
s->irq = irq;
s->dma = dma;
@@ -602,7 +602,7 @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta,
{
int iomemtype;
struct omap_mmc_s *s = (struct omap_mmc_s *)
qemu_mallocz(sizeof(struct omap_mmc_s));
g_malloc0(sizeof(struct omap_mmc_s));
s->irq = irq;
s->dma = dma;

View File

@@ -153,7 +153,7 @@ struct omap_sdrc_s *omap_sdrc_init(target_phys_addr_t base)
{
int iomemtype;
struct omap_sdrc_s *s = (struct omap_sdrc_s *)
qemu_mallocz(sizeof(struct omap_sdrc_s));
g_malloc0(sizeof(struct omap_sdrc_s));
omap_sdrc_reset(s);

View File

@@ -315,7 +315,7 @@ struct omap_mcspi_s *omap_mcspi_init(struct omap_target_agent_s *ta, int chnum,
{
int iomemtype;
struct omap_mcspi_s *s = (struct omap_mcspi_s *)
qemu_mallocz(sizeof(struct omap_mcspi_s));
g_malloc0(sizeof(struct omap_mcspi_s));
struct omap_mcspi_ch_s *ch = s->ch;
s->irq = irq;

View File

@@ -86,7 +86,7 @@ static CPUWriteMemoryFunc * const omap_synctimer_writefn[] = {
struct omap_synctimer_s *omap_synctimer_init(struct omap_target_agent_s *ta,
struct omap_mpu_state_s *mpu, omap_clk fclk, omap_clk iclk)
{
struct omap_synctimer_s *s = qemu_mallocz(sizeof(*s));
struct omap_synctimer_s *s = g_malloc0(sizeof(*s));
omap_synctimer_reset(s);
omap_l4_attach(ta, 0, l4_register_io_memory(

View File

@@ -55,7 +55,7 @@ struct omap_uart_s *omap_uart_init(target_phys_addr_t base,
const char *label, CharDriverState *chr)
{
struct omap_uart_s *s = (struct omap_uart_s *)
qemu_mallocz(sizeof(struct omap_uart_s));
g_malloc0(sizeof(struct omap_uart_s));
s->base = base;
s->fclk = fclk;

View File

@@ -186,7 +186,7 @@ static inline int onenand_prog_main(OneNANDState *s, int sec, int secn,
const uint8_t *sp = (const uint8_t *) src;
uint8_t *dp = 0;
if (s->bdrv_cur) {
dp = qemu_malloc(size);
dp = g_malloc(size);
if (!dp || bdrv_read(s->bdrv_cur, sec, dp, secn) < 0) {
result = 1;
}
@@ -207,7 +207,7 @@ static inline int onenand_prog_main(OneNANDState *s, int sec, int secn,
}
}
if (dp && s->bdrv_cur) {
qemu_free(dp);
g_free(dp);
}
}
@@ -239,7 +239,7 @@ static inline int onenand_prog_spare(OneNANDState *s, int sec, int secn,
const uint8_t *sp = (const uint8_t *) src;
uint8_t *dp = 0, *dpp = 0;
if (s->bdrv_cur) {
dp = qemu_malloc(512);
dp = g_malloc(512);
if (!dp || bdrv_read(s->bdrv_cur,
s->secs_cur + (sec >> 5),
dp, 1) < 0) {
@@ -265,7 +265,7 @@ static inline int onenand_prog_spare(OneNANDState *s, int sec, int secn,
}
}
if (dp) {
qemu_free(dp);
g_free(dp);
}
}
return result;
@@ -274,13 +274,13 @@ static inline int onenand_prog_spare(OneNANDState *s, int sec, int secn,
static inline int onenand_erase(OneNANDState *s, int sec, int num)
{
uint8_t *blankbuf, *tmpbuf;
blankbuf = qemu_malloc(512);
blankbuf = g_malloc(512);
if (!blankbuf) {
return 1;
}
tmpbuf = qemu_malloc(512);
tmpbuf = g_malloc(512);
if (!tmpbuf) {
qemu_free(blankbuf);
g_free(blankbuf);
return 1;
}
memset(blankbuf, 0xff, 512);
@@ -307,13 +307,13 @@ static inline int onenand_erase(OneNANDState *s, int sec, int num)
}
}
qemu_free(tmpbuf);
qemu_free(blankbuf);
g_free(tmpbuf);
g_free(blankbuf);
return 0;
fail:
qemu_free(tmpbuf);
qemu_free(blankbuf);
g_free(tmpbuf);
g_free(blankbuf);
return 1;
}
@@ -700,7 +700,7 @@ void *onenand_init(BlockDriverState *bdrv,
uint16_t man_id, uint16_t dev_id, uint16_t ver_id,
int regshift, qemu_irq irq)
{
OneNANDState *s = (OneNANDState *) qemu_mallocz(sizeof(*s));
OneNANDState *s = (OneNANDState *) g_malloc0(sizeof(*s));
uint32_t size = 1 << (24 + ((dev_id >> 4) & 7));
void *ram;
@@ -712,16 +712,16 @@ void *onenand_init(BlockDriverState *bdrv,
s->id.ver = ver_id;
s->blocks = size >> BLOCK_SHIFT;
s->secs = size >> 9;
s->blockwp = qemu_malloc(s->blocks);
s->blockwp = g_malloc(s->blocks);
s->density_mask = (dev_id & 0x08) ? (1 << (6 + ((dev_id >> 4) & 7))) : 0;
s->iomemtype = cpu_register_io_memory(onenand_readfn,
onenand_writefn, s, DEVICE_NATIVE_ENDIAN);
s->bdrv = bdrv;
if (!s->bdrv) {
s->image = memset(qemu_malloc(size + (size >> 5)),
s->image = memset(g_malloc(size + (size >> 5)),
0xff, size + (size >> 5));
}
s->otp = memset(qemu_malloc((64 + 2) << PAGE_SHIFT),
s->otp = memset(g_malloc((64 + 2) << PAGE_SHIFT),
0xff, (64 + 2) << PAGE_SHIFT);
s->ram = qemu_ram_alloc(NULL, "onenand.ram", 0xc000 << s->shift);
ram = qemu_get_ram_ptr(s->ram);

View File

@@ -1180,7 +1180,7 @@ qemu_irq *openpic_init (PCIBus *bus, MemoryRegion **pmem, int nb_cpus,
pci_register_bar(&opp->pci_dev, 0,
PCI_BASE_ADDRESS_SPACE_MEMORY, &opp->mem);
} else {
opp = qemu_mallocz(sizeof(openpic_t));
opp = g_malloc0(sizeof(openpic_t));
memory_region_init_io(&opp->mem, &openpic_ops, opp, "openpic", 0x40000);
}
@@ -1644,7 +1644,7 @@ qemu_irq *mpic_init (target_phys_addr_t base, int nb_cpus,
if (nb_cpus != 1)
return NULL;
mpp = qemu_mallocz(sizeof(openpic_t));
mpp = g_malloc0(sizeof(openpic_t));
for (i = 0; i < sizeof(list)/sizeof(list[0]); i++) {
int mem_index;
@@ -1676,6 +1676,6 @@ qemu_irq *mpic_init (target_phys_addr_t base, int nb_cpus,
return qemu_allocate_irqs(openpic_set_irq, mpp, mpp->max_irq);
free:
qemu_free(mpp);
g_free(mpp);
return NULL;
}

View File

@@ -565,7 +565,7 @@ bool parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
ParallelState *s;
int io_sw;
s = qemu_mallocz(sizeof(ParallelState));
s = g_malloc0(sizeof(ParallelState));
s->irq = irq;
s->chr = chr;
s->it_shift = it_shift;

22
hw/pc.c
View File

@@ -617,7 +617,7 @@ static void *bochs_bios_init(void)
* of nodes, one word for each VCPU->node and one word for each node to
* hold the amount of memory.
*/
numa_fw_cfg = qemu_mallocz((1 + smp_cpus + nb_numa_nodes) * 8);
numa_fw_cfg = g_malloc0((1 + smp_cpus + nb_numa_nodes) * 8);
numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes);
for (i = 0; i < smp_cpus; i++) {
for (j = 0; j < nb_numa_nodes; j++) {
@@ -788,7 +788,7 @@ static void load_linux(void *fw_cfg,
initrd_addr = (initrd_max-initrd_size) & ~4095;
initrd_data = qemu_malloc(initrd_size);
initrd_data = g_malloc(initrd_size);
load_image(initrd_filename, initrd_data);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr);
@@ -806,8 +806,8 @@ static void load_linux(void *fw_cfg,
setup_size = (setup_size+1)*512;
kernel_size -= setup_size;
setup = qemu_malloc(setup_size);
kernel = qemu_malloc(kernel_size);
setup = g_malloc(setup_size);
kernel = g_malloc(kernel_size);
fseek(f, 0, SEEK_SET);
if (fread(setup, 1, setup_size, f) != setup_size) {
fprintf(stderr, "fread() failed\n");
@@ -978,15 +978,15 @@ void pc_memory_init(MemoryRegion *system_memory,
* aliases to address portions of it, mostly for backwards compatiblity
* with older qemus that used qemu_ram_alloc().
*/
ram = qemu_malloc(sizeof(*ram));
ram = g_malloc(sizeof(*ram));
memory_region_init_ram(ram, NULL, "pc.ram",
below_4g_mem_size + above_4g_mem_size);
ram_below_4g = qemu_malloc(sizeof(*ram_below_4g));
ram_below_4g = g_malloc(sizeof(*ram_below_4g));
memory_region_init_alias(ram_below_4g, "ram-below-4g", ram,
0, below_4g_mem_size);
memory_region_add_subregion(system_memory, 0, ram_below_4g);
if (above_4g_mem_size > 0) {
ram_above_4g = qemu_malloc(sizeof(*ram_above_4g));
ram_above_4g = g_malloc(sizeof(*ram_above_4g));
memory_region_init_alias(ram_above_4g, "ram-above-4g", ram,
below_4g_mem_size, above_4g_mem_size);
memory_region_add_subregion(system_memory, 0x100000000ULL,
@@ -1006,7 +1006,7 @@ void pc_memory_init(MemoryRegion *system_memory,
(bios_size % 65536) != 0) {
goto bios_error;
}
bios = qemu_malloc(sizeof(*bios));
bios = g_malloc(sizeof(*bios));
memory_region_init_ram(bios, NULL, "pc.bios", bios_size);
memory_region_set_readonly(bios, true);
ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
@@ -1016,13 +1016,13 @@ void pc_memory_init(MemoryRegion *system_memory,
exit(1);
}
if (filename) {
qemu_free(filename);
g_free(filename);
}
/* map the last 128KB of the BIOS in ISA space */
isa_bios_size = bios_size;
if (isa_bios_size > (128 * 1024))
isa_bios_size = 128 * 1024;
isa_bios = qemu_malloc(sizeof(*isa_bios));
isa_bios = g_malloc(sizeof(*isa_bios));
memory_region_init_alias(isa_bios, "isa-bios", bios,
bios_size - isa_bios_size, isa_bios_size);
memory_region_add_subregion_overlap(system_memory,
@@ -1031,7 +1031,7 @@ void pc_memory_init(MemoryRegion *system_memory,
1);
memory_region_set_readonly(isa_bios, true);
option_rom_mr = qemu_malloc(sizeof(*option_rom_mr));
option_rom_mr = g_malloc(sizeof(*option_rom_mr));
memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE);
memory_region_add_subregion_overlap(system_memory,
PC_ROM_MIN_VGA,

View File

@@ -121,7 +121,7 @@ static void pc_init1(MemoryRegion *system_memory,
} else {
i8259 = xen_interrupt_controller_init();
}
isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state));
isa_irq_state = g_malloc0(sizeof(*isa_irq_state));
isa_irq_state->i8259 = i8259;
if (pci_enabled) {
ioapic_init(isa_irq_state);

View File

@@ -223,7 +223,7 @@ static int pcibus_reset(BusState *qbus)
static void pci_host_bus_register(int domain, PCIBus *bus)
{
struct PCIHostBus *host;
host = qemu_mallocz(sizeof(*host));
host = g_malloc0(sizeof(*host));
host->domain = domain;
host->bus = bus;
QLIST_INSERT_HEAD(&host_buses, host, next);
@@ -288,7 +288,7 @@ PCIBus *pci_bus_new(DeviceState *parent, const char *name,
{
PCIBus *bus;
bus = qemu_mallocz(sizeof(*bus));
bus = g_malloc0(sizeof(*bus));
bus->qbus.qdev_allocated = 1;
pci_bus_new_inplace(bus, parent, name, address_space_mem,
address_space_io, devfn_min);
@@ -302,7 +302,7 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
bus->map_irq = map_irq;
bus->irq_opaque = irq_opaque;
bus->nirq = nirq;
bus->irq_count = qemu_mallocz(nirq * sizeof(bus->irq_count[0]));
bus->irq_count = g_malloc0(nirq * sizeof(bus->irq_count[0]));
}
void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug, DeviceState *qdev)
@@ -346,13 +346,13 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
int i;
assert(size == pci_config_size(s));
config = qemu_malloc(size);
config = g_malloc(size);
qemu_get_buffer(f, config, size);
for (i = 0; i < size; ++i) {
if ((config[i] ^ s->config[i]) &
s->cmask[i] & ~s->wmask[i] & ~s->w1cmask[i]) {
qemu_free(config);
g_free(config);
return -EINVAL;
}
}
@@ -360,7 +360,7 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
pci_update_mappings(s);
qemu_free(config);
g_free(config);
return 0;
}
@@ -720,20 +720,20 @@ static void pci_config_alloc(PCIDevice *pci_dev)
{
int config_size = pci_config_size(pci_dev);
pci_dev->config = qemu_mallocz(config_size);
pci_dev->cmask = qemu_mallocz(config_size);
pci_dev->wmask = qemu_mallocz(config_size);
pci_dev->w1cmask = qemu_mallocz(config_size);
pci_dev->used = qemu_mallocz(config_size);
pci_dev->config = g_malloc0(config_size);
pci_dev->cmask = g_malloc0(config_size);
pci_dev->wmask = g_malloc0(config_size);
pci_dev->w1cmask = g_malloc0(config_size);
pci_dev->used = g_malloc0(config_size);
}
static void pci_config_free(PCIDevice *pci_dev)
{
qemu_free(pci_dev->config);
qemu_free(pci_dev->cmask);
qemu_free(pci_dev->wmask);
qemu_free(pci_dev->w1cmask);
qemu_free(pci_dev->used);
g_free(pci_dev->config);
g_free(pci_dev->cmask);
g_free(pci_dev->wmask);
g_free(pci_dev->w1cmask);
g_free(pci_dev->used);
}
/* -1 for devfn means auto assign */
@@ -825,7 +825,7 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name,
.config_write = config_write,
};
pci_dev = qemu_mallocz(instance_size);
pci_dev = g_malloc0(instance_size);
pci_dev = do_pci_register_device(pci_dev, bus, name, devfn, &info);
if (pci_dev == NULL) {
hw_error("PCI: can't register device\n");
@@ -865,7 +865,7 @@ static int pci_unregister_device(DeviceState *dev)
pci_unregister_io_regions(pci_dev);
pci_del_option_rom(pci_dev);
qemu_free(pci_dev->romfile);
g_free(pci_dev->romfile);
do_pci_unregister_device(pci_dev);
return 0;
}
@@ -1680,7 +1680,7 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
/* rom loading */
is_default_rom = false;
if (pci_dev->romfile == NULL && info->romfile != NULL) {
pci_dev->romfile = qemu_strdup(info->romfile);
pci_dev->romfile = g_strdup(info->romfile);
is_default_rom = true;
}
pci_add_option_rom(pci_dev, is_default_rom);
@@ -1896,14 +1896,14 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);
if (path == NULL) {
path = qemu_strdup(pdev->romfile);
path = g_strdup(pdev->romfile);
}
size = get_image_size(path);
if (size < 0) {
error_report("%s: failed to find romfile \"%s\"",
__FUNCTION__, pdev->romfile);
qemu_free(path);
g_free(path);
return -1;
}
if (size & (size - 1)) {
@@ -1918,7 +1918,7 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
memory_region_init_ram(&pdev->rom, &pdev->qdev, name, size);
ptr = memory_region_get_ram_ptr(&pdev->rom);
load_image(path, ptr);
qemu_free(path);
g_free(path);
if (is_default_rom) {
/* Only the default rom images will be patched (if needed). */
@@ -2108,7 +2108,7 @@ static char *pcibus_get_dev_path(DeviceState *dev)
path_len = domain_len + slot_len * slot_depth;
/* Allocate memory, fill in the terminating null byte. */
path = qemu_malloc(path_len + 1 /* For '\0' */);
path = g_malloc(path_len + 1 /* For '\0' */);
path[path_len] = '\0';
/* First field is the domain. */

View File

@@ -111,7 +111,7 @@ int pcie_aer_init(PCIDevice *dev, uint16_t offset)
if (dev->exp.aer_log.log_max > PCIE_AER_LOG_MAX_LIMIT) {
return -EINVAL;
}
dev->exp.aer_log.log = qemu_mallocz(sizeof dev->exp.aer_log.log[0] *
dev->exp.aer_log.log = g_malloc0(sizeof dev->exp.aer_log.log[0] *
dev->exp.aer_log.log_max);
pci_set_long(dev->w1cmask + offset + PCI_ERR_UNCOR_STATUS,
@@ -165,7 +165,7 @@ int pcie_aer_init(PCIDevice *dev, uint16_t offset)
void pcie_aer_exit(PCIDevice *dev)
{
qemu_free(dev->exp.aer_log.log);
g_free(dev->exp.aer_log.log);
}
static void pcie_aer_update_uncor_status(PCIDevice *dev)

View File

@@ -76,7 +76,7 @@ void pcie_chassis_create(uint8_t chassis_number)
if (c) {
return;
}
c = qemu_mallocz(sizeof(*c));
c = g_malloc0(sizeof(*c));
c->number = chassis_number;
QLIST_INIT(&c->slots);
QLIST_INSERT_HEAD(&chassis, c, next);

View File

@@ -416,7 +416,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
target_phys_addr_t base, ram_addr_t size,
target_phys_addr_t mask)
{
KBDState *s = qemu_mallocz(sizeof(KBDState));
KBDState *s = g_malloc0(sizeof(KBDState));
int s_io_memory;
s->irq_kbd = kbd_irq;

View File

@@ -88,7 +88,7 @@ static int petalogix_load_device_tree(target_phys_addr_t addr,
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (path) {
fdt = load_device_tree(path, &fdt_size);
qemu_free(path);
g_free(path);
}
if (!fdt) {
return 0;
@@ -108,7 +108,7 @@ static int petalogix_load_device_tree(target_phys_addr_t addr,
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (path) {
fdt_size = load_image_targphys(path, addr, 0x10000);
qemu_free(path);
g_free(path);
}
}

View File

@@ -75,7 +75,7 @@ static int petalogix_load_device_tree(target_phys_addr_t addr,
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (path) {
fdt = load_device_tree(path, &fdt_size);
qemu_free(path);
g_free(path);
}
if (!fdt)
return 0;
@@ -93,7 +93,7 @@ static int petalogix_load_device_tree(target_phys_addr_t addr,
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (path) {
fdt_size = load_image_targphys(path, addr, 0x10000);
qemu_free(path);
g_free(path);
}
}

Some files were not shown because too many files have changed in this diff Show More