-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
38 lines (35 loc) · 1.24 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ylagtab <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/30 15:40:18 by ylagtab #+# #+# */
/* Updated: 2020/10/14 12:02:00 by ylagtab ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t n)
{
unsigned char *d;
unsigned char *s;
size_t i;
if (dst == NULL || src == NULL)
return (NULL);
d = (unsigned char *)dst;
s = (unsigned char *)src;
if (dst < src)
{
i = 0;
while (i < n)
{
d[i] = s[i];
i++;
}
return (dst);
}
while (n--)
d[n] = s[n];
return (dst);
}