-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
35 lines (32 loc) · 1.29 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yochered <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/25 13:30:49 by yochered #+# #+# */
/* Updated: 2018/10/25 13:30:52 by yochered ### ########.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
void *ft_memmove(void *dst, const void *src, size_t len)
{
unsigned char *dst_tmp;
unsigned char *src_tmp;
size_t i;
i = -1;
dst_tmp = (unsigned char *)dst;
src_tmp = (unsigned char *)src;
if (src_tmp < dst_tmp)
{
while (len--)
*(dst_tmp + len) = *(src_tmp + len);
}
else
{
while (++i < len)
*(dst_tmp + i) = *(src_tmp + i);
}
return (dst);
}