-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
35 lines (32 loc) · 1.29 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erlajoua <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/17 12:14:57 by erlajoua #+# #+# */
/* Updated: 2020/11/17 12:14:57 by erlajoua ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
size_t i;
unsigned char *ptr_dst;
const unsigned char *ptr_src;
if (!dst && !src)
return (NULL);
ptr_dst = (unsigned char*)dst;
ptr_src = (unsigned char*)src;
i = 0;
if (ptr_dst > ptr_src)
while (++i <= len)
{
ptr_dst[len - i] = ptr_src[len - i];
}
else
while (len-- > 0)
*(ptr_dst++) = *(ptr_src++);
return (dst);
}