[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently
From: |
Paul Brook |
Subject: |
Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently |
Date: |
Tue, 2 Jun 2009 21:04:54 +0100 |
User-agent: |
KMail/1.11.2 (Linux/2.6.29-2-amd64; KDE/4.2.2; x86_64; ; ) |
On Tuesday 02 June 2009, David Turner wrote:
> On Tue, Jun 2, 2009 at 8:13 PM, Paul Brook <address@hidden> wrote:
> > > > QEMU_NEW_ARRAY(ptr, ...);
> > > >
> > > > instead of
> > > >
> > > > ptr = QEMU_NEW_ARRAY(...);
> > > >
> > > > then. I don't see another easy way to get the automagic sizeof(*ptr)
> > > > stuff done though.
> > >
> > > The first version will extract the item size automatically for you,
> >
> > making
> >
> > > it less likely that you screw things in the second version's parameter
> > > list.
> >
> > Not if you do it properly it won't.
>
> Very frankly I don't see your point.
My point is that
#define QEMU_NEW(type) ((type *)qemu_malloc(sizeof(type)))
foo *ptr = QEMU_NEW(foo);
is just as safe as
#define QEMU_NEW(ptr) (ptr) = qemu_malloc(sizeof(*(ptr)))
foo *ptr;
QEMU_NEW(ptr);
Because the compiler will catch the type mismatch.
Paul
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, (continued)
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, jcd, 2009/06/01
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Gerd Hoffmann, 2009/06/02
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Avi Kivity, 2009/06/02
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, David Turner, 2009/06/02
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Paul Brook, 2009/06/02
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, David Turner, 2009/06/02
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently,
Paul Brook <=
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, David Turner, 2009/06/02
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Gerd Hoffmann, 2009/06/02
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Gerd Hoffmann, 2009/06/02
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Paul Brook, 2009/06/02
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, David Turner, 2009/06/02
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Avi Kivity, 2009/06/02