38 lines
1.2 KiB
C
38 lines
1.2 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_memmove.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2022/09/27 11:44:12 by cchauvet #+# #+# */
|
||
|
/* Updated: 2022/09/28 16:40:24 by cchauvet ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "libft.h"
|
||
|
|
||
|
void *ft_memmove(void *dest, const void *src, size_t n)
|
||
|
{
|
||
|
size_t i;
|
||
|
char *tab1;
|
||
|
char *tab2;
|
||
|
|
||
|
if (dest == NULL && src == NULL)
|
||
|
return (dest);
|
||
|
tab1 = dest;
|
||
|
tab2 = (void *) src;
|
||
|
if (tab1 < tab2)
|
||
|
ft_memcpy(dest, src, n);
|
||
|
else
|
||
|
{
|
||
|
i = n;
|
||
|
while (0 < i)
|
||
|
{
|
||
|
i--;
|
||
|
tab1[i] = tab2[i];
|
||
|
}
|
||
|
}
|
||
|
return (dest);
|
||
|
}
|