-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
31 lines (28 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pabmart2 <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/10 21:04:01 by pabmart2 #+# #+# */
/* Updated: 2024/09/19 21:09:23 by pabmart2 ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
unsigned char *temp_dest;
const unsigned char *temp_src;
if (dest == src || n == 0)
return (dest);
if (src < dest && dest < src + n)
{
temp_dest = (unsigned char *)dest + n;
temp_src = (unsigned char *)src + n;
while (n--)
*(--temp_dest) = *(--temp_src);
return (dest);
}
return (ft_memcpy(dest, src, n));
}