From: Markus Armbruster Date: Thu, 29 Oct 2015 15:55:21 +0000 (+0100) Subject: qxl: Use g_new() & friends where that makes obvious sense X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~121^2~1^2~87^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9de68637dff05a18d0eafcff2737e551b70bc490;p=sdk%2Femulator%2Fqemu.git qxl: 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 Reviewed-by: Eric Blake Reviewed-by: Gerd Hoffmann Signed-off-by: Michael Tokarev --- diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 9c961dae93..8a3040cbbf 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2156,7 +2156,7 @@ static int qxl_post_load(void *opaque, int version) qxl_create_guest_primary(d, 1, QXL_SYNC); /* replay surface-create and cursor-set commands */ - cmds = g_malloc0(sizeof(QXLCommandExt) * (d->ssd.num_surfaces + 1)); + cmds = g_new0(QXLCommandExt, d->ssd.num_surfaces + 1); for (in = 0, out = 0; in < d->ssd.num_surfaces; in++) { if (d->guest_surfaces.cmds[in] == 0) { continue;