From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NH3kN-0006Jh-6W for qemu-devel@nongnu.org; Sat, 05 Dec 2009 18:09:03 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NH3kL-0006JB-7Z for qemu-devel@nongnu.org; Sat, 05 Dec 2009 18:09:01 -0500 Received: from [199.232.76.173] (port=58636 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NH3kL-0006J8-4M for qemu-devel@nongnu.org; Sat, 05 Dec 2009 18:09:01 -0500 Received: from bhuna.collabora.co.uk ([93.93.128.226]:52179) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NH3kK-0001oD-AN for qemu-devel@nongnu.org; Sat, 05 Dec 2009 18:09:00 -0500 Message-ID: <4B1AE7E3.9000905@collabora.co.uk> Date: Sat, 05 Dec 2009 23:08:19 +0000 From: Ian Molton MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends References: <4B193DA5.6040507@codemonkey.ws> <4B1A9359.8080305@redhat.com> <4B1A9BF4.2090909@redhat.com> In-Reply-To: <4B1A9BF4.2090909@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Blue Swirl , Paul Brook , Markus Armbruster , qemu-devel@nongnu.org Avi Kivity wrote: > Only if you allocate using POSIX malloc(). If you allocate using a > function that is defined to return a valid pointer for zero length > allocations, you're happy. Wouldnt it be better to, rather than use a qemu_malloc() that is utterly counterintuitive in that it has no way to report failure, and behaves in ways people dont expect, to use normal malloc() and never pass it 0 ? Seriously, who does that anyway? why call malloc when you dont want the space? so you can use realloc? 99.99% of the time realloc() is the Wrong Solution(tm). stick to what people know, and LART them for misuse of it if necessary. (Just my 2p) -Ian