mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06: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:
parent
71e28e3cc2
commit
58889fe50a
3 changed files with 5 additions and 5 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue