From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MBb4U-0008Gu-7S for qemu-devel@nongnu.org; Tue, 02 Jun 2009 16:58:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MBb4P-0008Bq-GZ for qemu-devel@nongnu.org; Tue, 02 Jun 2009 16:58:57 -0400 Received: from [199.232.76.173] (port=44306 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MBb4P-0008Ba-3N for qemu-devel@nongnu.org; Tue, 02 Jun 2009 16:58:53 -0400 Received: from mx20.gnu.org ([199.232.41.8]:1903) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MBb4O-0004GZ-OK for qemu-devel@nongnu.org; Tue, 02 Jun 2009 16:58:52 -0400 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MBb4N-0006eE-SE for qemu-devel@nongnu.org; Tue, 02 Jun 2009 16:58:52 -0400 From: Paul Brook Subject: Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently Date: Tue, 2 Jun 2009 21:58:48 +0100 References: <200905290758.11551.jcd@tribudubois.net> <200906022104.55121.paul@codesourcery.com> <60cad3f0906021342s36cdbd52r6056ed552ba1ae82@mail.gmail.com> In-Reply-To: <60cad3f0906021342s36cdbd52r6056ed552ba1ae82@mail.gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200906022158.49202.paul@codesourcery.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , David Turner , Gerd Hoffmann , Jean-Christophe Dubois > I think you're afraid of the following case instead: > > foo* ptr; > ptr =3D QEMU_MEW(bar); =3D> 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 < #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 =3D QEMU_NEW(bar); return 0; } EOF gcc test.c test.c: In function =E2=80=98main=E2=80=99: test.c:7: initialization from incompatible pointer type Paul