-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
37 lines (34 loc) · 1.27 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
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: esuguimo <esuguimo@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/21 15:08:52 by esuguimo #+# #+# */
/* Updated: 2020/02/28 02:26:52 by esuguimo ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
unsigned char *dest;
unsigned char *source;
size_t i;
dest = (unsigned char *)dst;
source = (unsigned char *)src;
i = 0;
if (!src && !dst)
return (NULL);
if (src < dst)
{
source += len;
dest += len;
while (len--)
*(--dest) = *(--source);
}
else
while (len--)
*(dest++) = *(source++);
return (dst);
}