aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/string.c')
-rw-r--r--tools/perf/util/string.c18
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 @@
1#include "util.h" 1#include "util.h"
2#include "string.h" 2#include "linux/string.h"
3 3
4#define K 1024LL 4#define K 1024LL
5/* 5/*
@@ -335,3 +335,19 @@ char *rtrim(char *s)
335 335
336 return s; 336 return s;
337} 337}
338
339/**
340 * memdup - duplicate region of memory
341 * @src: memory region to duplicate
342 * @len: memory region length
343 */
344void *memdup(const void *src, size_t len)
345{
346 void *p;
347
348 p = malloc(len);
349 if (p)
350 memcpy(p, src, len);
351
352 return p;
353}