-
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.29 KB
/
ft_memmove.c
File metadata and controls
42 lines (39 loc) · 1.29 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
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_memmove.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: thperchi <marvin@le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/07/10 04:05:25 by thperchi #+# ## ## #+# */
/* Updated: 2018/10/09 17:52:29 by thperchi ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t n)
{
unsigned char *s;
unsigned char *d;
s = (unsigned char *)src;
d = (unsigned char *)dst;
if (s < d)
{
s = s + n - 1;
d = d + n - 1;
while (n > 0)
{
*d-- = *s--;
n--;
}
}
else
{
while (n > 0)
{
*d++ = *s++;
n--;
}
}
return (dst);
}