blob: dee44f3f3cc91cc9b446831183b6c87b968d34ab (
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
42
|
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_memmove.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: rbousset <marvin@le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2019/10/08 18:57:44 by rbousset #+# ## ## #+# */
/* Updated: 2019/10/13 08:38:47 by rbousset ### #+. /#+ ###.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);
}
|