mirror of
https://github.com/mii443/qemu.git
synced 2025-08-23 15:48:20 +00:00
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 <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
committed by
Stefan Hajnoczi
parent
71e28e3cc2
commit
58889fe50a
@ -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;
|
||||
|
Reference in New Issue
Block a user