-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memmove.c
More file actions
38 lines (35 loc) · 1.3 KB
/
Copy pathft_memmove.c
File metadata and controls
38 lines (35 loc) · 1.3 KB
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: ophuong <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/06 20:26:03 by ophuong #+# #+# */
/* Updated: 2019/09/18 18:07:04 by ophuong ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
unsigned char *dest;
unsigned char *sourc;
if (dst == NULL && src == NULL)
return (NULL);
if (dst == src)
return (dst);
dest = (unsigned char *)dst + (len - 1);
sourc = (unsigned char *)src + (len - 1);
if (sourc < dest)
{
while (len--)
{
*dest = *sourc;
dest--;
sourc--;
}
}
else
ft_memcpy(dst, src, len);
return (dst);
}