-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memmove.c
More file actions
50 lines (45 loc) · 1.37 KB
/
Copy pathft_memmove.c
File metadata and controls
50 lines (45 loc) · 1.37 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
46
47
48
49
50
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gargrigo <gargrigo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/06 16:57:36 by gargrigo #+# #+# */
/* Updated: 2026/02/06 16:57:38 by gargrigo ### ########.fr */
/* */
/* ************************************************************************** */
#include <stddef.h>
static void helper(const unsigned char *s, unsigned char *d, size_t n)
{
size_t i;
i = 0;
if (d < s)
{
while (i < n)
{
d[i] = s[i];
i++;
}
}
else
{
i = n;
while (i > 0)
{
d[i - 1] = s[i - 1];
i--;
}
}
}
void *ft_memmove(void *dest, const void *src, size_t n)
{
unsigned char *d;
const unsigned char *s;
if (n == 0 || dest == src)
return (dest);
d = (unsigned char *)dest;
s = (const unsigned char *)src;
helper(s, d, n);
return (dest);
}