-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathft_memmove.c
41 lines (38 loc) · 1.25 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
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vbrazas <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/10/30 17:11:58 by vbrazas #+# #+# */
/* Updated: 2017/11/19 14:54:38 by vbrazas ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
unsigned char *s;
unsigned char *d;
size_t i;
if (len == 0)
return (dst);
s = (unsigned char *)src;
d = (unsigned char *)dst;
i = 0;
if (dst > src)
{
while (--len != 0)
d[len] = s[len];
d[len] = s[len];
}
else
{
while (i < len)
{
d[i] = s[i];
i++;
}
}
return (d);
}