qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org, Paul Brook <paul@codesourcery.com>
Subject: Re: [Qemu-devel] [PATCH] fix qemu_malloc(0)
Date: Fri, 29 May 2009 04:39:10 -0500	[thread overview]
Message-ID: <4A1FAD3E.2080900@codemonkey.ws> (raw)
In-Reply-To: <1243589633-14142-1-git-send-email-kraxel@redhat.com>

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 <kraxel@redhat.com>
>   

Acked-by: Anthony Liguori <aliguori@us.ibm.com>

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)
>   

      reply	other threads:[~2009-05-29  9:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-29  9:33 [Qemu-devel] [PATCH] fix qemu_malloc(0) Gerd Hoffmann
2009-05-29  9:39 ` Anthony Liguori [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A1FAD3E.2080900@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=kraxel@redhat.com \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).