mirror of
https://github.com/mii443/qemu.git
synced 2025-12-17 01:28:52 +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
@@ -652,7 +652,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str,
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
fwd = g_malloc(sizeof(struct GuestFwd));
|
||||
fwd = g_new(struct GuestFwd, 1);
|
||||
fwd->hd = qemu_chr_new(buf, p, NULL);
|
||||
if (!fwd->hd) {
|
||||
error_report("could not open guest forwarding device '%s'", buf);
|
||||
|
||||
Reference in New Issue
Block a user