From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M6Vxz-0005UU-Jh for qemu-devel@nongnu.org; Tue, 19 May 2009 16:31:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M6Vxu-0005Ha-4V for qemu-devel@nongnu.org; Tue, 19 May 2009 16:31:14 -0400 Received: from [199.232.76.173] (port=36874 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6Vxt-0005HH-WF for qemu-devel@nongnu.org; Tue, 19 May 2009 16:31:10 -0400 Received: from mail2.shareable.org ([80.68.89.115]:33895) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M6Vxt-0004mQ-G6 for qemu-devel@nongnu.org; Tue, 19 May 2009 16:31:09 -0400 Date: Tue, 19 May 2009 21:31:00 +0100 From: Jamie Lokier Subject: Re: [Qemu-devel] [PATCH] fix qemu_malloc() error check for size==0 Message-ID: <20090519203100.GB3986@shareable.org> References: <20090518221705.GO2079@blackpad> <8763fxvbfk.fsf@pike.pond.sub.org> <87octpnrhr.fsf@pike.pond.sub.org> <20090519142847.GC4254@blackpad> <20090519145653.GE4254@blackpad> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090519145653.GE4254@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: > I really hope you are not proposing to make qemu_realloc(p, 0) work but > qemu_malloc(0) fail, because you would be breaking lots of > realloc()/malloc() equivalency assumptions. Careful. realloc(p, 0) *always* frees p (or does nothing if p == NULL), on all systems complying with ISO C, and always returns NULL. malloc(0) on the other hand does not guarantee this, so malloc(0) is *not* a substitute for realloc(NULL, 0). -- Jamie