From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjqLz-0006FG-N0 for qemu-devel@nongnu.org; Tue, 13 Sep 2016 12:14:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjqLv-0007rp-AH for qemu-devel@nongnu.org; Tue, 13 Sep 2016 12:14:35 -0400 From: Michael Tokarev Date: Tue, 13 Sep 2016 19:04:45 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PULL 06/16] sparc: Use g_memdup() instead of g_new0() + memcpy() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Thomas Huth , qemu-trivial@nongnu.org, Michael Tokarev From: Thomas Huth 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 Acked-By: Artyom Tarasenko Signed-off-by: Michael Tokarev --- 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 e4089f2..800a25a 100644 --- a/target-sparc/cpu.c +++ b/target-sparc/cpu.c @@ -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); -- 2.1.4