Use g_new() & friends where that makes obvious sense
commitc5e8d51824fe725d0693cd9f50171d34297c5cc0
authorMarkus Armbruster <armbru@redhat.com>
Fri, 23 Sep 2022 08:42:54 +0000 (23 10:42 +0200)
committerLaurent Vivier <laurent@vivier.eu>
Mon, 3 Oct 2022 22:10:11 +0000 (4 00:10 +0200)
treeed7b4ecb99371f483a2694493450be78623d91b9
parent76eb88b12baf2bd9a1729ded33bd58b7da5d7ec3
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).

Patch created mechanically with:

    $ spatch --in-place --sp-file scripts/coccinelle/use-g_new-etc.cocci \
     --macro-file scripts/cocci-macro-file.h FILES...

The previous iteration was commit a95942b50c.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20220923084254.4173111-1-armbru@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
hw/remote/iommu.c
hw/virtio/virtio-crypto.c
migration/dirtyrate.c
softmmu/dirtylimit.c