-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
40 lines (37 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
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: olachgue <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/04 13:24:55 by olachgue #+# #+# */
/* Updated: 2024/11/11 13:23:44 by olachgue ### ########.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 (dst == src || len == 0)
return (dst);
s = (unsigned char *)src;
d = (unsigned char *)dst;
i = 0;
if (dst > src)
{
while (len--)
d[len] = s[len];
}
else
{
while (i < len)
{
d[i] = s[i];
i++;
}
}
return (dst);
}