diff options
author | Markus Armbruster <armbru@redhat.com> | 2014-12-04 14:46:45 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-12-15 12:21:02 +0100 |
commit | ab3ad07f89c7f9e03c17c98e1d1a02dbf61c605c (patch) | |
tree | 13eeaac95f3437959d8e861ff4207a0db70264af /hw/i386 | |
parent | 4be34d1e2140b6d1be611c4bfa542c54c232520b (diff) |
x86: 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>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/i386')
-rw-r--r-- | hw/i386/pc.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 8be50a4ad6..60c1d54b6d 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -601,8 +601,7 @@ int e820_add_entry(uint64_t address, uint64_t length, uint32_t type) } /* new "etc/e820" file -- include ram too */ - e820_table = g_realloc(e820_table, - sizeof(struct e820_entry) * (e820_entries+1)); + e820_table = g_renew(struct e820_entry, e820_table, e820_entries + 1); e820_table[e820_entries].address = cpu_to_le64(address); e820_table[e820_entries].length = cpu_to_le64(length); e820_table[e820_entries].type = cpu_to_le32(type); |