On 07/25/2011 12:32 PM, Alexander Graf wrote:
On 25.07.2011, at 10:51, Avi Kivity wrote:

>  qemu_malloc() is type-unsafe as it returns a void pointer.  Introduce
>  QEMU_NEW() (and QEMU_NEWZ()), which return the correct type.

What does this buy you over

type *x = qemu_malloc(sizeof(type));

? I find the non-C++ version easier to read even.


I'm using it as

    MemoryRegion *phys_flash = QEMU_NEW(MemoryRegion);

instead of

    MemoryRegion *phys_flash = qemu_malloc(sizeof(*phys_flash));

I find it shorter, and if I make a mistake, the compiler shouts at me instead of a runtime crash.

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to