[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] bring xxx-user qemu_malloc behavior up to speed
From: |
malc |
Subject: |
Re: [Qemu-devel] [PATCH] bring xxx-user qemu_malloc behavior up to speed with main qemu_malloc |
Date: |
Mon, 7 Sep 2009 00:43:22 +0400 (MSD) |
On Sun, 6 Sep 2009, Jean-Christophe DUBOIS wrote:
> the linux-user and bsd-user qemu_malloc behavior is not the same as
> the main qemu_malloc behavior
>
> This patch tries to make the xxx-user behavior on par with the main
> qemu_malloc behavior. In particular qemu_malloc and friends should
> abort if memory allocation fails.
>
> It also add the qemu_strdup and qemu_strndup function that were
> missing.
>
> Signed-off-by: Jean-Christophe Dubois <address@hidden>
> ---
> bsd-user/mmap.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++-----
> linux-user/mmap.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++-----
> 2 files changed, 99 insertions(+), 12 deletions(-)
>
[..snip..]
>
> +char *qemu_strdup(const char *str)
> +{
> + char *ptr;
> + size_t len = strlen(str);
> + ptr = qemu_malloc(len + 1);
> +
> + if (ptr)
> + memcpy(ptr, str, len + 1);
> +
> + return ptr;
> +}
If qemu_malloc can not return NULL anymore then following is in order:
return memcpy(ptr, str, len + 1);
Likewise elsewhere.
[..snip..]
--
mailto:address@hidden