From aed5df31b78d03fceb460a4fae36611c940a5a1d Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Sun, 25 Feb 2018 23:19:38 -0500 Subject: [PATCH] sparc: Use g_memdup() instead of g_new0() + memcpy() 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. Backports commit a337f295defad7eb977da4d6317cf70f7f2fa4b4 from qemu --- qemu/target-sparc/cpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qemu/target-sparc/cpu.c b/qemu/target-sparc/cpu.c index f890fdd4..ca811455 100644 --- a/qemu/target-sparc/cpu.c +++ b/qemu/target-sparc/cpu.c @@ -109,8 +109,7 @@ static int cpu_sparc_register(struct uc_struct *uc, SPARCCPU *cpu, const char *c 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);