diff options
| author | Arnaldo Carvalho de Melo <[email protected]> | 2015-11-16 14:36:29 +0000 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <[email protected]> | 2015-11-18 20:51:02 +0000 |
| commit | 4ddd32741da87657113d964588ce13ee64b34820 (patch) | |
| tree | c6ef98fadb95631fb72bf05c45a6f97b9ca92c04 /tools/lib/string.c | |
| parent | tools: Fix selftests_install Makefile rule (diff) | |
| download | kernel-4ddd32741da87657113d964588ce13ee64b34820.tar.gz kernel-4ddd32741da87657113d964588ce13ee64b34820.zip | |
tools: Adopt memdup() from tools/perf, moving it to tools/lib/string.c
That will contain more string functions with counterparts, sometimes
verbatim copies, in the kernel.
Acked-by: Wang Nan <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Diffstat (limited to 'tools/lib/string.c')
| -rw-r--r-- | tools/lib/string.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/lib/string.c b/tools/lib/string.c new file mode 100644 index 000000000000..ecfd43a9b24e --- /dev/null +++ b/tools/lib/string.c @@ -0,0 +1,19 @@ +#include <stdlib.h> +#include <string.h> +#include <linux/string.h> + +/** + * memdup - duplicate region of memory + * + * @src: memory region to duplicate + * @len: memory region length + */ +void *memdup(const void *src, size_t len) +{ + void *p = malloc(len); + + if (p) + memcpy(p, src, len); + + return p; +} |
