-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
44 lines (40 loc) · 1.4 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
41
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lfilloux <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/02 15:09:08 by lfilloux #+# #+# */
/* Updated: 2021/11/05 14:23:22 by lfilloux ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
size_t i;
unsigned char *source;
unsigned char *dest;
i = -1;
dest = (unsigned char *)dst;
source = (unsigned char *)src;
if (!dst && !src)
return (NULL);
if (dest > source)
while (len--)
dest[len] = source[len];
else
{
while (++i, len--)
dest[i] = source[i];
}
return (dest);
}
/*
int main(void)
{
printf("%s || ", memmove(((void *)0), ((void *)0), 5));
printf("%s\n", memmove(((void *)0), ((void *)0), 5));
return (0);
}
*/