提交 b232e073 编写于 作者: J Jiri Olsa 提交者: Arnaldo Carvalho de Melo

perf tools: Add memdup function

Adding memdup function to duplicate region of memory.

  void *memdup(const void *src, size_t len)
Signed-off-by: NJiri 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.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 bdde3716
#include <string.h>
void *memdup(const void *src, size_t len);
#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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册