Arnaldo Carvalho de Melo | 4ddd327 | 2015-11-16 11:36:29 -0300 | [diff] [blame^] | 1 | #include <stdlib.h> |
2 | #include <string.h> | ||||
3 | #include <linux/string.h> | ||||
4 | |||||
5 | /** | ||||
6 | * memdup - duplicate region of memory | ||||
7 | * | ||||
8 | * @src: memory region to duplicate | ||||
9 | * @len: memory region length | ||||
10 | */ | ||||
11 | void *memdup(const void *src, size_t len) | ||||
12 | { | ||||
13 | void *p = malloc(len); | ||||
14 | |||||
15 | if (p) | ||||
16 | memcpy(p, src, len); | ||||
17 | |||||
18 | return p; | ||||
19 | } |