From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M9yYa-00072a-LQ for qemu-devel@nongnu.org; Fri, 29 May 2009 05:39:20 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M9yYV-0006xf-FP for qemu-devel@nongnu.org; Fri, 29 May 2009 05:39:20 -0400 Received: from [199.232.76.173] (port=52453 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M9yYU-0006xN-Va for qemu-devel@nongnu.org; Fri, 29 May 2009 05:39:15 -0400 Received: from mail-qy0-f123.google.com ([209.85.221.123]:54861) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M9yYU-0005m7-Hb for qemu-devel@nongnu.org; Fri, 29 May 2009 05:39:14 -0400 Received: by qyk29 with SMTP id 29so6540210qyk.4 for ; Fri, 29 May 2009 02:39:13 -0700 (PDT) Message-ID: <4A1FAD3E.2080900@codemonkey.ws> Date: Fri, 29 May 2009 04:39:10 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] fix qemu_malloc(0) References: <1243589633-14142-1-git-send-email-kraxel@redhat.com> In-Reply-To: <1243589633-14142-1-git-send-email-kraxel@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org, Paul Brook Gerd Hoffmann wrote: > Don't abort. Return malloc(1) instead as suggested by Anthony. > > Likewise kill the abort call in qemu_realloc(), we can just call > free(ptr) for the size == 0 case to match realloc() behavior. > > Signed-off-by: Gerd Hoffmann > Acked-by: Anthony Liguori But we're going to have to get some more input from other maintainers before making a final decision. Regards, Anthony Liguori > --- > qemu-malloc.c | 9 +++------ > 1 files changed, 3 insertions(+), 6 deletions(-) > > diff --git a/qemu-malloc.c b/qemu-malloc.c > index 295d185..4193fdb 100644 > --- a/qemu-malloc.c > +++ b/qemu-malloc.c > @@ -45,7 +45,7 @@ void qemu_free(void *ptr) > void *qemu_malloc(size_t size) > { > if (!size) { > - abort(); > + size = 1; > } > return oom_check(malloc(size)); > } > @@ -54,12 +54,9 @@ void *qemu_realloc(void *ptr, size_t size) > { > if (size) { > return oom_check(realloc(ptr, size)); > - } else { > - if (ptr) { > - return realloc(ptr, size); > - } > } > - abort(); > + free(ptr); > + return NULL; > } > > void *qemu_mallocz(size_t size) >