-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memmove.c
39 lines (36 loc) · 1.2 KB
/
ft_memmove.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
34
35
36
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nvienot <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/14 18:21:48 by nvienot #+# #+# */
/* Updated: 2018/11/20 17:05:59 by nvienot ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
size_t i;
char *dst2;
const char *src2;
i = -1;
dst2 = (char*)dst;
src2 = (const char*)src;
if (dst2 < src2)
{
while (++i < len)
{
dst2[i] = src2[i];
}
}
else
{
while (len-- > 0)
{
dst2[len] = src2[len];
}
}
return (dst2);
}