aboutsummaryrefslogtreecommitdiff
path: root/savevm.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-08-20 22:09:37 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2011-08-20 23:01:08 -0500
commit7267c0947d7e8ae5dff7bafd932c3bc285f43e5c (patch)
tree9aa05d6e05ed83e67bf014f6745a3081b8407dc5 /savevm.c
parent14015304b662e8f8ccce46c5a6927af6a14c510b (diff)
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>
Diffstat (limited to 'savevm.c')
-rw-r--r--savevm.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/savevm.c b/savevm.c
index 7801aa7056..b06308b56a 100644
--- a/savevm.c
+++ b/savevm.c
@@ -206,7 +206,7 @@ static int socket_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
static int socket_close(void *opaque)
{
QEMUFileSocket *s = opaque;
- qemu_free(s);
+ g_free(s);
return 0;
}
@@ -234,7 +234,7 @@ static int stdio_pclose(void *opaque)
QEMUFileStdio *s = opaque;
int ret;
ret = pclose(s->stdio_file);
- qemu_free(s);
+ g_free(s);
return ret;
}
@@ -242,7 +242,7 @@ static int stdio_fclose(void *opaque)
{
QEMUFileStdio *s = opaque;
fclose(s->stdio_file);
- qemu_free(s);
+ g_free(s);
return 0;
}
@@ -255,7 +255,7 @@ QEMUFile *qemu_popen(FILE *stdio_file, const char *mode)
return NULL;
}
- s = qemu_mallocz(sizeof(QEMUFileStdio));
+ s = g_malloc0(sizeof(QEMUFileStdio));
s->stdio_file = stdio_file;
@@ -303,7 +303,7 @@ QEMUFile *qemu_fdopen(int fd, const char *mode)
return NULL;
}
- s = qemu_mallocz(sizeof(QEMUFileStdio));
+ s = g_malloc0(sizeof(QEMUFileStdio));
s->stdio_file = fdopen(fd, mode);
if (!s->stdio_file)
goto fail;
@@ -318,13 +318,13 @@ QEMUFile *qemu_fdopen(int fd, const char *mode)
return s->file;
fail:
- qemu_free(s);
+ g_free(s);
return NULL;
}
QEMUFile *qemu_fopen_socket(int fd)
{
- QEMUFileSocket *s = qemu_mallocz(sizeof(QEMUFileSocket));
+ QEMUFileSocket *s = g_malloc0(sizeof(QEMUFileSocket));
s->fd = fd;
s->file = qemu_fopen_ops(s, NULL, socket_get_buffer, socket_close,
@@ -358,7 +358,7 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode)
return NULL;
}
- s = qemu_mallocz(sizeof(QEMUFileStdio));
+ s = g_malloc0(sizeof(QEMUFileStdio));
s->stdio_file = fopen(filename, mode);
if (!s->stdio_file)
@@ -373,7 +373,7 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode)
}
return s->file;
fail:
- qemu_free(s);
+ g_free(s);
return NULL;
}
@@ -411,7 +411,7 @@ QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
{
QEMUFile *f;
- f = qemu_mallocz(sizeof(QEMUFile));
+ f = g_malloc0(sizeof(QEMUFile));
f->opaque = opaque;
f->put_buffer = put_buffer;
@@ -477,7 +477,7 @@ int qemu_fclose(QEMUFile *f)
qemu_fflush(f);
if (f->close)
ret = f->close(f->opaque);
- qemu_free(f);
+ g_free(f);
return ret;
}
@@ -1114,7 +1114,7 @@ int register_savevm_live(DeviceState *dev,
{
SaveStateEntry *se;
- se = qemu_mallocz(sizeof(SaveStateEntry));
+ se = g_malloc0(sizeof(SaveStateEntry));
se->version_id = version_id;
se->section_id = global_section_id++;
se->set_params = set_params;
@@ -1130,9 +1130,9 @@ int register_savevm_live(DeviceState *dev,
if (id) {
pstrcpy(se->idstr, sizeof(se->idstr), id);
pstrcat(se->idstr, sizeof(se->idstr), "/");
- qemu_free(id);
+ g_free(id);
- se->compat = qemu_mallocz(sizeof(CompatEntry));
+ se->compat = g_malloc0(sizeof(CompatEntry));
pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), idstr);
se->compat->instance_id = instance_id == -1 ?
calculate_compat_instance_id(idstr) : instance_id;
@@ -1174,7 +1174,7 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
if (path) {
pstrcpy(id, sizeof(id), path);
pstrcat(id, sizeof(id), "/");
- qemu_free(path);
+ g_free(path);
}
}
pstrcat(id, sizeof(id), idstr);
@@ -1183,9 +1183,9 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
QTAILQ_REMOVE(&savevm_handlers, se, entry);
if (se->compat) {
- qemu_free(se->compat);
+ g_free(se->compat);
}
- qemu_free(se);
+ g_free(se);
}
}
}
@@ -1203,7 +1203,7 @@ void register_device_unmigratable(DeviceState *dev, const char *idstr,
if (path) {
pstrcpy(id, sizeof(id), path);
pstrcat(id, sizeof(id), "/");
- qemu_free(path);
+ g_free(path);
}
}
pstrcat(id, sizeof(id), idstr);
@@ -1225,7 +1225,7 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
/* If this triggers, alias support can be dropped for the vmsd. */
assert(alias_id == -1 || required_for_version >= vmsd->minimum_version_id);
- se = qemu_mallocz(sizeof(SaveStateEntry));
+ se = g_malloc0(sizeof(SaveStateEntry));
se->version_id = vmsd->version_id;
se->section_id = global_section_id++;
se->save_live_state = NULL;
@@ -1241,9 +1241,9 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
if (id) {
pstrcpy(se->idstr, sizeof(se->idstr), id);
pstrcat(se->idstr, sizeof(se->idstr), "/");
- qemu_free(id);
+ g_free(id);
- se->compat = qemu_mallocz(sizeof(CompatEntry));
+ se->compat = g_malloc0(sizeof(CompatEntry));
pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->name);
se->compat->instance_id = instance_id == -1 ?
calculate_compat_instance_id(vmsd->name) : instance_id;
@@ -1279,9 +1279,9 @@ void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
if (se->vmsd == vmsd && se->opaque == opaque) {
QTAILQ_REMOVE(&savevm_handlers, se, entry);
if (se->compat) {
- qemu_free(se->compat);
+ g_free(se->compat);
}
- qemu_free(se);
+ g_free(se);
}
}
}
@@ -1785,7 +1785,7 @@ int qemu_loadvm_state(QEMUFile *f)
}
/* Add entry */
- le = qemu_mallocz(sizeof(*le));
+ le = g_malloc0(sizeof(*le));
le->se = se;
le->section_id = section_id;
@@ -1835,7 +1835,7 @@ int qemu_loadvm_state(QEMUFile *f)
out:
QLIST_FOREACH_SAFE(le, &loadvm_handlers, entry, new_le) {
QLIST_REMOVE(le, entry);
- qemu_free(le);
+ g_free(le);
}
if (qemu_file_has_error(f))
@@ -1862,7 +1862,7 @@ static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
break;
}
}
- qemu_free(sn_tab);
+ g_free(sn_tab);
return ret;
}
@@ -2141,7 +2141,7 @@ void do_info_snapshots(Monitor *mon)
return;
}
- available_snapshots = qemu_mallocz(sizeof(int) * nb_sns);
+ available_snapshots = g_malloc0(sizeof(int) * nb_sns);
total = 0;
for (i = 0; i < nb_sns; i++) {
sn = &sn_tab[i];
@@ -2174,7 +2174,7 @@ void do_info_snapshots(Monitor *mon)
monitor_printf(mon, "There is no suitable snapshot available\n");
}
- qemu_free(sn_tab);
- qemu_free(available_snapshots);
+ g_free(sn_tab);
+ g_free(available_snapshots);
}