mirror of
https://github.com/mii443/qemu.git
synced 2025-12-16 17:18:49 +00:00
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>
This commit is contained in:
committed by
Amit Shah
parent
56f3835ff1
commit
97f3ad3551
@@ -440,7 +440,7 @@ QEMUFile *qemu_bufopen(const char *mode, QEMUSizedBuffer *input)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s = g_malloc0(sizeof(QEMUBuffer));
|
||||
s = g_new0(QEMUBuffer, 1);
|
||||
s->qsb = input;
|
||||
|
||||
if (s->qsb == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user