diff options
author | Markus Armbruster <armbru@redhat.com> | 2014-12-04 14:28:17 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2014-12-19 13:17:02 +0000 |
commit | 58889fe50a7c5b8776cf3096a8fe611fb66c4e5c (patch) | |
tree | c5cf3f17b67b4cfe5573942b02b78a7435d86dfe /net/slirp.c | |
parent | 71e28e3cc24ff3b0268903758aae357592eb8b74 (diff) | |
download | hqemu-58889fe50a7c5b8776cf3096a8fe611fb66c4e5c.zip hqemu-58889fe50a7c5b8776cf3096a8fe611fb66c4e5c.tar.gz |
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>
Diffstat (limited to 'net/slirp.c')
-rw-r--r-- | net/slirp.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/slirp.c b/net/slirp.c index 377d7ef..0cbca3c 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -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); |