-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
36 lines (33 loc) · 1.21 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ysaito <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/06/27 14:19:37 by ysaito #+# #+# */
/* Updated: 2021/11/01 20:47:48 by ysaito ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
char *dp;
char *sp;
dp = (char *)dst;
sp = (char *)src;
if (len == 0 || dp == sp)
return (dst);
else if (dp < sp)
return (ft_memcpy(dst, src, len));
else
{
dp += len - 1;
sp += len - 1;
while (len--)
{
*dp-- = *sp--;
}
}
return (dst);
}