-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memmove.c
More file actions
45 lines (41 loc) · 1.55 KB
/
ft_memmove.c
File metadata and controls
45 lines (41 loc) · 1.55 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
43
44
45
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_memmove.c :+: :+: */
/* +:+ */
/* By: jaberkro <jaberkro@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2021/10/18 21:27:06 by jaberkro #+# #+# */
/* Updated: 2021/10/18 22:17:13 by jaberkro ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
size_t counter;
counter = 0;
if (dst == NULL && src == NULL)
return (dst);
if ((unsigned char *)dst <= (unsigned char *)src)
{
while (counter < len)
{
((unsigned char *)dst)[counter] = ((unsigned char *)src)[counter];
counter++;
}
}
else
{
while (len > 0)
{
len--;
((unsigned char *)dst)[len] = ((unsigned char *)src)[len];
}
}
return (dst);
}
/* The memmove() function copies len bytes from string src to string dst.
The two strings may overlap; the copy is always done in a non-destructive
manner.
The memmove() function returns the original value of dst.
*/