diff options
author | Markus Armbruster <armbru@redhat.com> | 2015-09-14 13:51:31 +0200 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2015-09-29 11:36:35 +0530 |
commit | 97f3ad35517e0d02c0149637d1bb10713c52b057 (patch) | |
tree | 73f29aa9a4099bf48ceb0708bd1706fe6852b04d /migration/qemu-file-stdio.c | |
parent | 56f3835ff1e70df97f843f4a27abdff6b4a2ae77 (diff) | |
download | qemu-97f3ad35517e0d02c0149637d1bb10713c52b057.tar.gz qemu-97f3ad35517e0d02c0149637d1bb10713c52b057.tar.bz2 qemu-97f3ad35517e0d02c0149637d1bb10713c52b057.zip |
migration: Use g_new() & friends where that makes obvious sense
g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer,
for two reasons. One, it catches multiplication overflowing size_t.
Two, it returns T * rather than void *, which lets the compiler catch
more type errors.
This commit only touches allocations with size arguments of the form
sizeof(T). Same Coccinelle semantic patch as in commit b45c03f.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1442231491-23352-1-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'migration/qemu-file-stdio.c')
-rw-r--r-- | migration/qemu-file-stdio.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/migration/qemu-file-stdio.c b/migration/qemu-file-stdio.c index dc91137b9c..889ffb302c 100644 --- a/migration/qemu-file-stdio.c +++ b/migration/qemu-file-stdio.c @@ -144,7 +144,7 @@ QEMUFile *qemu_popen_cmd(const char *command, const char *mode) return NULL; } - s = g_malloc0(sizeof(QEMUFileStdio)); + s = g_new0(QEMUFileStdio, 1); s->stdio_file = stdio_file; @@ -176,7 +176,7 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode) return NULL; } - s = g_malloc0(sizeof(QEMUFileStdio)); + s = g_new0(QEMUFileStdio, 1); s->stdio_file = fopen(filename, mode); if (!s->stdio_file) { |