Re: [Qemu-devel] [PATCH v2 1/2] spapr_pci: convert g_malloc() to g_new()

2018-10-14 Thread David Gibson
On Fri, Oct 12, 2018 at 11:05:09AM +0200, Greg Kurz wrote: > 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

Re: [Qemu-devel] [PATCH v2 1/2] spapr_pci: convert g_malloc() to g_new()

2018-10-12 Thread Philippe Mathieu-Daudé
On 12/10/2018 11:05, Greg Kurz wrote: > 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 all

[Qemu-devel] [PATCH v2 1/2] spapr_pci: convert g_malloc() to g_new()

2018-10-12 Thread Greg Kurz
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. Si