[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [Qemu-Devel] [PATCH] Changed malloc to g_malloc, free t
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [Qemu-Devel] [PATCH] Changed malloc to g_malloc, free to g_free in linux-user/qemu.h |
Date: |
Wed, 30 Mar 2016 15:09:55 +0100 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Thu, Mar 24, 2016 at 12:02:03AM +0530, Md Haris Iqbal wrote:
> Signed-off-by: Md Haris Iqbal <address@hidden>
> ---
> linux-user/qemu.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/qemu.h b/linux-user/qemu.h
> index 26b0ba2..3c3fd15 100644
> --- a/linux-user/qemu.h
> +++ b/linux-user/qemu.h
> @@ -381,7 +381,7 @@ static inline void *lock_user(int type, abi_ulong
> guest_addr, long len, int copy
> #ifdef DEBUG_REMAP
> {
> void *addr;
> - addr = malloc(len);
> + addr = g_malloc(len);
> if (copy)
> memcpy(addr, g2h(guest_addr), len);
> else
> @@ -407,7 +407,7 @@ static inline void unlock_user(void *host_ptr, abi_ulong
> guest_addr,
> return;
> if (len > 0)
> memcpy(g2h(guest_addr), host_ptr, len);
> - free(host_ptr);
> + g_free(host_ptr);
> #endif
> }
If I understand correctly either lock_user() or lock_user_string() may
be followed by unlock_user(). If you change unlock_user() to g_free()
then you also need to change lock_user_string() to g_malloc() to avoid a
malloc()/g_free() mismatch.
signature.asc
Description: PGP signature