From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MBayE-0001P2-77 for qemu-devel@nongnu.org; Tue, 02 Jun 2009 16:52:30 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MBay9-0001KN-IW for qemu-devel@nongnu.org; Tue, 02 Jun 2009 16:52:29 -0400 Received: from [199.232.76.173] (port=58627 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MBay9-0001K2-0t for qemu-devel@nongnu.org; Tue, 02 Jun 2009 16:52:25 -0400 Received: from mx2.redhat.com ([66.187.237.31]:34722) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MBay8-0002jn-C5 for qemu-devel@nongnu.org; Tue, 02 Jun 2009 16:52:24 -0400 Message-ID: <4A25900E.4000202@redhat.com> Date: Tue, 02 Jun 2009 22:48:14 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently References: <200905290758.11551.jcd@tribudubois.net> <200906021913.09517.paul@codesourcery.com> <60cad3f0906021249t435fc1a8w4f89027e0863ff52@mail.gmail.com> <200906022104.55121.paul@codesourcery.com> <60cad3f0906021342s36cdbd52r6056ed552ba1ae82@mail.gmail.com> In-Reply-To: <60cad3f0906021342s36cdbd52r6056ed552ba1ae82@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Turner Cc: Kevin Wolf , Jean-Christophe Dubois , Paul Brook , qemu-devel@nongnu.org On 06/02/09 22:42, David Turner wrote: >> #define QEMU_NEW(type) ((type *)qemu_malloc(sizeof(type))) >> foo *ptr = QEMU_NEW(foo); >> #define QEMU_NEW(ptr) (ptr) = qemu_malloc(sizeof(*(ptr))) >> foo *ptr; >> QEMU_NEW(ptr); > I still don't see the point. Point is: The first version is nicer than the second, and you are still type safe due to the compiler warning on stuff like this: > foo* ptr; > ptr = QEMU_MEW(bar); cheers, Gerd