diff options
author | Greg Kurz | 2018-10-12 11:05:09 +0200 |
---|---|---|
committer | David Gibson | 2018-11-08 02:04:40 +0100 |
commit | 4fc4c6a53d69af50c4421857c749f84f927d09f6 (patch) | |
tree | c26144500fd3061441c406ccfcaa350c2788c69f /hw/ppc/spapr_pci.c | |
parent | target/ppc: Split out float_invalid_cvt (diff) | |
download | qemu-4fc4c6a53d69af50c4421857c749f84f927d09f6.tar.gz qemu-4fc4c6a53d69af50c4421857c749f84f927d09f6.tar.xz qemu-4fc4c6a53d69af50c4421857c749f84f927d09f6.zip |
spapr_pci: convert g_malloc() to g_new()
When allocating an array, it is a recommended coding practice to call
g_new(FooType, n) instead of g_malloc(n * sizeof(FooType)) because
it takes care to avoid overflow when calculating the size of the
allocated block and it returns FooType *, which allows the compiler
to perform type checking.
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'hw/ppc/spapr_pci.c')
-rw-r--r-- | hw/ppc/spapr_pci.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 58afa46204..2374d55fc1 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1882,7 +1882,7 @@ static int spapr_pci_pre_save(void *opaque) if (!sphb->msi_devs_num) { return 0; } - sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig)); + sphb->msi_devs = g_new(spapr_pci_msi_mig, sphb->msi_devs_num); g_hash_table_iter_init(&iter, sphb->msi); for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) { |