-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
35 lines (32 loc) · 1.25 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nopereir <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/09 23:37:22 by nopereir #+# #+# */
/* Updated: 2022/06/09 23:59:15 by nopereir ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
unsigned char *aux_dest;
unsigned char *aux_src;
size_t idx;
aux_src = (unsigned char *)src;
aux_dest = (unsigned char *)dest;
idx = n;
if (aux_src < aux_dest)
{
while (idx)
{
idx--;
aux_dest[idx] = aux_src[idx];
}
return (dest);
}
ft_memcpy(aux_dest, aux_src, n);
return (dest);
}