sparc: Use g_memdup() instead of g_new0() + memcpy()
authorThomas Huth <thuth@redhat.com>
Thu, 16 Jun 2016 17:33:38 +0000 (19:33 +0200)
committerMichael Tokarev <mjt@gandalf>
Tue, 13 Sep 2016 15:12:34 +0000 (18:12 +0300)
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 <thuth@redhat.com>
Acked-By: Artyom Tarasenko <atar4qemu@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
target-sparc/cpu.c

index e4089f2..800a25a 100644 (file)
@@ -117,8 +117,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, ",");
     sparc_cpu_parse_features(CPU(cpu), featurestr, &err);