Skip to contentSkip to conversation

perf tools: Use memdup in map__clone

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Jan 31, 2013 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  8e16017d497e9bb37c8c3c5ed1edb8d6adeebf3a
Gitweb:     http://git.kernel.org/tip/8e16017d497e9bb37c8c3c5ed1edb8d6adeebf3a
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Thu, 24 Jan 2013 22:16:43 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 25 Jan 2013 12:49:28 -0300

perf tools: Use memdup in map__clone

We have memdup() exactly for that, remove open coded dup.

Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/util/map.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
tools/perf/util/map.c +2 -6
index b6b1636..6fcb9de 100644
@@ -11,6 +11,7 @@
 #include "strlist.h"
 #include "vdso.h"
 #include "build-id.h"
+#include <linux/string.h>
 
 const char *map_type__name[MAP__NR_TYPES] = {
 	[MAP__FUNCTION] = "Functions",
@@ -213,12 +214,7 @@ struct symbol *map__find_symbol_by_name(struct map *map, const char *name,
 
 struct map *map__clone(struct map *map)
 {
-	struct map *clone = malloc(sizeof(*clone));
-
-	if (clone != NULL)
-		memcpy(clone, map, sizeof(*clone));
-
-	return clone;
+	return memdup(map, sizeof(*map));
 }
 
 int map__overlap(struct map *l, struct map *r)