From 8ab7cf56bd907c295f8cd2660b57f4a469b3fbe0 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Mon, 10 Sep 2012 18:50:17 +0200 Subject: [PATCH] --- yaml --- r: 323806 b: refs/heads/master c: b232e0732b1d763834c3d5b098d25d59337ba075 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/tools/perf/util/include/linux/string.h | 2 ++ trunk/tools/perf/util/string.c | 18 +++++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index ff54a24393c0..9aebfb49515d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: bdde37163e1fd474509aab90f5eaacee46100107 +refs/heads/master: b232e0732b1d763834c3d5b098d25d59337ba075 diff --git a/trunk/tools/perf/util/include/linux/string.h b/trunk/tools/perf/util/include/linux/string.h index 3b2f5900276f..6f19c548ecc0 100644 --- a/trunk/tools/perf/util/include/linux/string.h +++ b/trunk/tools/perf/util/include/linux/string.h @@ -1 +1,3 @@ #include + +void *memdup(const void *src, size_t len); diff --git a/trunk/tools/perf/util/string.c b/trunk/tools/perf/util/string.c index 199bc4d8905d..32170590892d 100644 --- a/trunk/tools/perf/util/string.c +++ b/trunk/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; +}