forked from Minki/linux
4ddd32741d
That will contain more string functions with counterparts, sometimes verbatim copies, in the kernel. Acked-by: Wang Nan <wangnan0@huawei.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/n/tip-rah6g97kn21vfgmlramorz6o@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
20 lines
297 B
C
20 lines
297 B
C
#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;
|
|
}
|