[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [PATCH] sparc: Use g_memdup() instead of g_new0() + m
From: |
Artyom Tarasenko |
Subject: |
Re: [Qemu-trivial] [PATCH] sparc: Use g_memdup() instead of g_new0() + memcpy() |
Date: |
Fri, 17 Jun 2016 13:38:16 +0200 |
Acked-By: Artyom Tarasenko <address@hidden>
On Thu, Jun 16, 2016 at 7:33 PM, Thomas Huth <address@hidden> wrote:
> There is no need to make sure that the memory is zeroed after the
> allocation if we also immediatly fill the whole buffer afterwards
> with memcpy(). Thus g_new0 should be g_new instead. But since we
> are also doing a memcpy() here, we can also simply replace both
> with g_memdup() instead.
>
> Signed-off-by: Thomas Huth <address@hidden>
> ---
> target-sparc/cpu.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/target-sparc/cpu.c b/target-sparc/cpu.c
> index 5b74cfc..7b43192 100644
> --- a/target-sparc/cpu.c
> +++ b/target-sparc/cpu.c
> @@ -115,8 +115,7 @@ static int cpu_sparc_register(SPARCCPU *cpu, const char
> *cpu_model)
> return -1;
> }
>
> - env->def = g_new0(sparc_def_t, 1);
> - memcpy(env->def, def, sizeof(*def));
> + env->def = g_memdup(def, sizeof(*def));
>
> featurestr = strtok(NULL, ",");
> cc->parse_features(CPU(cpu), featurestr, &err);
> --
> 1.8.3.1
>
--
Regards,
Artyom Tarasenko
SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu