|
| From: | Paul Brook |
| Subject: | Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently |
| Date: | Tue, 2 Jun 2009 21:58:48 +0100 |
| User-agent: | KMail/1.11.2 (Linux/2.6.29-2-amd64; KDE/4.2.2; x86_64; ; ) |
> I think you're afraid of the following case instead:
>
> foo* ptr;
> ptr = QEMU_MEW(bar); => compiler will complain that 'ptr' is not a bar*
>
>But this is not possible with the first version anyway.
Rubbish. Works perfectly.
cat test.c <<EOF
#include <stdlib.h>
#define QEMU_NEW(type) (type*)malloc(sizeof(type))
typedef struct { int x; } foo;
typedef struct { double y; } bar;
int main(int argc, char **argv)
{
foo *ptr = QEMU_NEW(bar);
return 0;
}
EOF
gcc test.c
test.c: In function ‘main’:
test.c:7: initialization from incompatible pointer type
Paul
| [Prev in Thread] | Current Thread | [Next in Thread] |