Skip to content

Commit

Permalink
perf tools: Use memdup in map__clone
Browse files Browse the repository at this point in the history
We have memdup() exactly for that, remove open coded dup.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-tnsoexrgv6u9l125srq2c7su@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Jan 25, 2013
1 parent 237a7e0 commit 8e16017
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions tools/perf/util/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8e16017

Please sign in to comment.