From 58889fe50a7c5b8776cf3096a8fe611fb66c4e5c Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 4 Dec 2014 14:28:17 +0100 Subject: net: 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). Signed-off-by: Markus Armbruster Signed-off-by: Stefan Hajnoczi --- net/queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/queue.c') diff --git a/net/queue.c b/net/queue.c index f948318718..ebbe2bb93b 100644 --- a/net/queue.c +++ b/net/queue.c @@ -62,7 +62,7 @@ NetQueue *qemu_new_net_queue(void *opaque) { NetQueue *queue; - queue = g_malloc0(sizeof(NetQueue)); + queue = g_new0(NetQueue, 1); queue->opaque = opaque; queue->nq_maxlen = 10000; -- cgit 1.4.1