-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
32 lines (30 loc) · 1.18 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oelkhiar <oelkhiar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/17 11:14:51 by oelkhiar #+# #+# */
/* Updated: 2022/11/20 12:28:17 by oelkhiar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t n)
{
if (!dst && !src)
return (NULL);
if (dst == src)
return (dst);
if (dst > src)
{
while (n > 0)
{
((unsigned char *)dst)[n - 1] = ((unsigned char *)src)[n - 1];
n--;
}
}
else
ft_memcpy(dst, src, n);
return (dst);
}