diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-01-24 20:24:57 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-01-25 10:49:28 -0500 |
commit | 8d9233f205e8855dc762665e28012354cd46af45 (patch) | |
tree | 4002477057de2bfb92bf9084c1b8268477233adb /tools/perf/builtin-kmem.c | |
parent | 8e16017d497e9bb37c8c3c5ed1edb8d6adeebf3a (diff) |
perf kmem: Use memdup()
Instead of hand coded equivalent.
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-42ldngi973f4ssvzlklo8t2k@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-kmem.c')
-rw-r--r-- | tools/perf/builtin-kmem.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index c746108c5d48..46878daca5cc 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include "util/debug.h" | 17 | #include "util/debug.h" |
18 | 18 | ||
19 | #include <linux/rbtree.h> | 19 | #include <linux/rbtree.h> |
20 | #include <linux/string.h> | ||
20 | 21 | ||
21 | struct alloc_stat; | 22 | struct alloc_stat; |
22 | typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *); | 23 | typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *); |
@@ -618,12 +619,11 @@ static int sort_dimension__add(const char *tok, struct list_head *list) | |||
618 | 619 | ||
619 | for (i = 0; i < NUM_AVAIL_SORTS; i++) { | 620 | for (i = 0; i < NUM_AVAIL_SORTS; i++) { |
620 | if (!strcmp(avail_sorts[i]->name, tok)) { | 621 | if (!strcmp(avail_sorts[i]->name, tok)) { |
621 | sort = malloc(sizeof(*sort)); | 622 | sort = memdup(avail_sorts[i], sizeof(*avail_sorts[i])); |
622 | if (!sort) { | 623 | if (!sort) { |
623 | pr_err("%s: malloc failed\n", __func__); | 624 | pr_err("%s: memdup failed\n", __func__); |
624 | return -1; | 625 | return -1; |
625 | } | 626 | } |
626 | memcpy(sort, avail_sorts[i], sizeof(*sort)); | ||
627 | list_add_tail(&sort->list, list); | 627 | list_add_tail(&sort->list, list); |
628 | return 0; | 628 | return 0; |
629 | } | 629 | } |