diff options
author | 2012-09-10 18:50:17 +0200 | |
---|---|---|
committer | 2012-09-11 12:04:41 -0300 | |
commit | b232e0732b1d763834c3d5b098d25d59337ba075 (patch) | |
tree | 8efb458e33231aa64779c0bfa5bf34dbf7f0d819 /tools/perf/util/string.c | |
parent | perf tools: Do backtrace post unwind only if we regs and stack were captured (diff) | |
download | linux-b232e0732b1d763834c3d5b098d25d59337ba075.tar.gz linux-b232e0732b1d763834c3d5b098d25d59337ba075.tar.bz2 linux-b232e0732b1d763834c3d5b098d25d59337ba075.zip |
perf tools: Add memdup function
Adding memdup function to duplicate region of memory.
void *memdup(const void *src, size_t len)
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1347295819-23177-3-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/string.c')
-rw-r--r-- | tools/perf/util/string.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index 199bc4d8905d..32170590892d 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c @@ -1,5 +1,5 @@ #include "util.h" -#include "string.h" +#include "linux/string.h" #define K 1024LL /* @@ -335,3 +335,19 @@ char *rtrim(char *s) return s; } + +/** + * memdup - duplicate region of memory + * @src: memory region to duplicate + * @len: memory region length + */ +void *memdup(const void *src, size_t len) +{ + void *p; + + p = malloc(len); + if (p) + memcpy(p, src, len); + + return p; +} |