-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memmove.c
34 lines (31 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hwong <hwong@student.42kl.edu.my> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/03 11:49:10 by hwong #+# #+# */
/* Updated: 2022/10/03 11:49:10 by hwong ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t n)
{
unsigned char *point_dst;
unsigned char *point_src;
point_dst = (unsigned char *)dst;
point_src = (unsigned char *)src;
if (!dst && !src)
return (dst);
if (dst < src)
ft_memcpy(dst, src, n);
else
{
point_dst += n;
point_src += n;
while (n-- > 0)
*(--point_dst) = *(--point_src);
}
return (dst);
}