From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M6VzE-0007N6-Pj for qemu-devel@nongnu.org; Tue, 19 May 2009 16:32:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M6Vz9-0007DF-K2 for qemu-devel@nongnu.org; Tue, 19 May 2009 16:32:31 -0400 Received: from [199.232.76.173] (port=34611 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6Vz9-0007Cw-AH for qemu-devel@nongnu.org; Tue, 19 May 2009 16:32:27 -0400 Received: from mail2.shareable.org ([80.68.89.115]:33905) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M6Vz8-00052U-Rc for qemu-devel@nongnu.org; Tue, 19 May 2009 16:32:27 -0400 Date: Tue, 19 May 2009 21:32:23 +0100 From: Jamie Lokier Subject: Re: [Qemu-devel] [PATCH] fix qemu_malloc() error check for size==0 Message-ID: <20090519203223.GC3986@shareable.org> References: <8763fxvbfk.fsf@pike.pond.sub.org> <87octpnrhr.fsf@pike.pond.sub.org> <20090519142847.GC4254@blackpad> <20090519145653.GE4254@blackpad> <20090519154317.GF4254@blackpad> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090519154317.GF4254@blackpad> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: malc , Markus Armbruster , qemu-devel@nongnu.org Eduardo Habkost wrote: > Now, _that_ sounds like a really bad idea. realloc(NULL, n) is specified > to be equivalent to malloc(n). No it isn't. You can't make that substitution. In the case where n == 0, realloc(NULL, n) is guaranteed to not allocate anything and return NULL, whereas malloc(n) does not guarantee that and in fact doesn't do that on a lot of implementations. -- Jamie