From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlMpk-0006BI-BV for qemu-devel@nongnu.org; Mon, 25 Jul 2011 11:12:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlMpi-0001Mj-Ip for qemu-devel@nongnu.org; Mon, 25 Jul 2011 11:12:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35349) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlMpi-0001MU-Bp for qemu-devel@nongnu.org; Mon, 25 Jul 2011 11:12:38 -0400 Message-ID: <4E2D876C.3010300@redhat.com> Date: Mon, 25 Jul 2011 17:10:36 +0200 From: Jes Sorensen MIME-Version: 1.0 References: <1311583872-362-1-git-send-email-avi@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Avi Kivity , kvm@vger.kernel.org, qemu-devel@nongnu.org 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