mirror of
https://github.com/mii443/qemu.git
synced 2025-12-16 17:18:49 +00:00
usb: 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). Same Coccinelle semantic patch as in commit b45c03f.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
committed by
Michael Tokarev
parent
9de68637df
commit
98f343395e
@@ -359,8 +359,7 @@ static void usb_mtp_object_readdir(MTPState *s, MTPObject *o)
|
||||
}
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
if ((o->nchildren % 32) == 0) {
|
||||
o->children = g_realloc(o->children,
|
||||
(o->nchildren + 32) * sizeof(MTPObject *));
|
||||
o->children = g_renew(MTPObject *, o->children, o->nchildren + 32);
|
||||
}
|
||||
o->children[o->nchildren] =
|
||||
usb_mtp_object_alloc(s, s->next_handle++, o, entry->d_name);
|
||||
|
||||
Reference in New Issue
Block a user