-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
36 lines (33 loc) · 1.24 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
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alalaoui <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/04/18 18:30:27 by alalaoui #+# #+# */
/* Updated: 2017/04/27 18:11:09 by alalaoui ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <string.h>
#include <stdlib.h>
void *ft_memmove(void *dst, const void *src, size_t len)
{
unsigned char *d;
unsigned char *s;
d = (unsigned char*)dst;
s = (unsigned char*)src;
if (!len || s == d)
return (dst);
if (d < s)
ft_memcpy(dst, src, len);
else
{
d = d + len;
s = s + len;
while (len--)
*--d = *--s;
}
return (dst);
}