blob: 977cd84f6f66d86a5b6a24eeb220a17673e17968 (
plain)
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
41
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: joelecle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:06:42 by joelecle #+# #+# */
/* Updated: 2020/02/14 17:06:42 by joelecle ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <stddef.h>
void
*ft_memmove(void *dst, const void *src, size_t len)
{
const char *from = (const char*)src;
char *to;
int i;
size_t j;
to = (char*)dst;
if (to > from && to - from < (int)len)
{
i = len;
while (--i >= 0)
to[i] = from[i];
return (dst);
}
if (from > to && from - to < (int)len)
{
j = -1;
while (++j < len)
to[j] = from[j];
return (dst);
}
ft_memcpy(dst, src, len);
return (dst);
}
|