-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
33 lines (30 loc) · 1.2 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: asoler <asoler@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/06 19:16:47 by asoler #+# #+# */
/* Updated: 2022/04/25 16:55:04 by asoler ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
unsigned char *sdest;
unsigned char *ssrc;
sdest = (unsigned char *)dest;
ssrc = (unsigned char *)src;
if (sdest < ssrc)
{
ft_memcpy(dest, src, n);
return (dest);
}
while (n != 0)
{
sdest[n - 1] = ssrc[n - 1];
n--;
}
return ((void *)sdest);
}