-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memmove.c
More file actions
42 lines (39 loc) · 1.31 KB
/
Copy pathft_memmove.c
File metadata and controls
42 lines (39 loc) · 1.31 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
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: obouizi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/22 20:43:25 by obouizi #+# #+# */
/* Updated: 2024/10/24 11:26:46 by obouizi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
unsigned char *ptr_dst;
const unsigned char *ptr_src;
size_t i;
ptr_dst = dst;
ptr_src = src;
i = 0;
if (ptr_dst == ptr_src || len == 0)
return (dst);
if (ptr_dst < ptr_src)
{
while (i < len)
{
ptr_dst[i] = ptr_src[i];
i++;
}
}
else if (ptr_dst > ptr_src)
{
while (len-- > 0)
{
ptr_dst[len] = ptr_src[len];
}
}
return (dst);
}