-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memdup.c
33 lines (30 loc) · 1.16 KB
/
ft_memdup.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tseguier <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/04/15 20:20:51 by tseguier #+# #+# */
/* Updated: 2014/04/19 02:41:28 by tseguier ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
void *ft_memdup(void *mem, size_t len)
{
void *newmem;
size_t i;
if (!mem)
return (NULL);
i = 0;
newmem = malloc(len);
if (!newmem)
return (NULL);
while (i < len)
{
*((char *)(newmem + i)) = *((char *)(mem + i));
++i;
}
return (newmem);
}