mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
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>
This commit is contained in:
parent
bdde37163e
commit
b232e0732b
2 changed files with 19 additions and 1 deletions
|
@ -1 +1,3 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
void *memdup(const void *src, size_t len);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "string.h"
|
#include "linux/string.h"
|
||||||
|
|
||||||
#define K 1024LL
|
#define K 1024LL
|
||||||
/*
|
/*
|
||||||
|
@ -335,3 +335,19 @@ char *rtrim(char *s)
|
||||||
|
|
||||||
return 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;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue