From 2d528d45ecf5ee3c1a566a9f3d664464925ef830 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 14 Sep 2015 13:54:03 +0200 Subject: qemu-char: 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 Message-Id: <1442231643-23630-1-git-send-email-armbru@redhat.com> Signed-off-by: Paolo Bonzini --- backends/testdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/testdev.c b/backends/testdev.c index eba396a..1429152 100644 --- a/backends/testdev.c +++ b/backends/testdev.c @@ -113,8 +113,8 @@ CharDriverState *chr_testdev_init(void) TestdevCharState *testdev; CharDriverState *chr; - testdev = g_malloc0(sizeof(TestdevCharState)); - testdev->chr = chr = g_malloc0(sizeof(CharDriverState)); + testdev = g_new0(TestdevCharState, 1); + testdev->chr = chr = g_new0(CharDriverState, 1); chr->opaque = testdev; chr->chr_write = testdev_write; -- cgit v1.1