Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/25/11 12:06, Stefan Hajnoczi wrote:
>> +#define QEMU_NEW(type) ((type *)(qemu_malloc(sizeof(type))))
>> > +#define QEMU_NEWZ(type) ((type *)(qemu_mallocz(sizeof(type))))
> Does this mean we need to duplicate the type name for each allocation?
> 
> struct foo *f;
> 
> ...
> f = qemu_malloc(sizeof(*f));
> 
> Becomes:
> 
> struct foo *f;
> 
> ...
> f = QEMU_NEW(struct foo);
> 
> If you ever change the name of the type you have to search-replace
> these instances.  The idomatic C way works well, I don't see a reason
> to use QEMU_NEW().

You're right, and it will promote even more abuse of the ugly typedefs.
This really makes the code less readable, especially for outsiders :(

Jes


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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux