[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW()
From: |
Jes Sorensen |
Subject: |
Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW() |
Date: |
Mon, 25 Jul 2011 17:10:36 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Thunderbird/3.1.11 |
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
Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW(), Avi Kivity, 2011/07/25
Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW(), Stefan Hajnoczi, 2011/07/25
Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW(),
Jes Sorensen <=
- Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW(), Anthony Liguori, 2011/07/25
- Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW(), Jes Sorensen, 2011/07/25
- Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW(), Avi Kivity, 2011/07/25
- Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW(), Jes Sorensen, 2011/07/25
- Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW(), Avi Kivity, 2011/07/25
- Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW(), Jes Sorensen, 2011/07/25
- Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW(), Avi Kivity, 2011/07/25
Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW(), Anthony Liguori, 2011/07/25