Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHaAC-0003Ne-JI for qemu-devel@nongnu.org; Mon, 07 Dec 2009 04:45:52 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHaA8-0003M0-Rg for qemu-devel@nongnu.org; Mon, 07 Dec 2009 04:45:52 -0500 Received: from [199.232.76.173] (port=57048 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHaA8-0003Lt-Et for qemu-devel@nongnu.org; Mon, 07 Dec 2009 04:45:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25718) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHaA8-0001x9-3d for qemu-devel@nongnu.org; Mon, 07 Dec 2009 04:45:48 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends References: <4B193DA5.6040507@codemonkey.ws> <4B1A9359.8080305@redhat.com> <4B1A9811.8020108@codemonkey.ws> <4B1BE153.6070509@collabora.co.uk> Date: Mon, 07 Dec 2009 10:45:39 +0100 In-Reply-To: <4B1BE153.6070509@collabora.co.uk> (Ian Molton's message of "Sun, 06 Dec 2009 16:52:35 +0000") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ian Molton Cc: Avi Kivity , Paul Brook , qemu-devel@nongnu.org Ian Molton writes: > Markus Armbruster wrote: > >> p = malloc(n * sizeof(struct foo); >> if (n && !p) >> exit_no_mem(); >> for (i = 0; i < n; i++) >> compute_one(p, i); >> >> With qemu_malloc(), the error handling moves into qemu_malloc(): >> >> p = qemu_malloc(n * sizeof(struct foo); >> for (i = 0; i < n; i++) >> compute_one(p, i); > > And you lose the ability to fail gracefully... That's a deliberate choice. It has its drawbacks, it has its advantages. And it's not related to the question at hand: permitting zero arguments.