libft/memory/ft_memmove.c
Raphael ed64bd73d6
docs(memory): moving the actual documentation on the header
- The documentation on the header allow u to see on the files where the
header is inclued
2025-09-05 16:29:40 +02:00

51 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:51:35 by rparodi #+# #+# */
/* Updated: 2025/09/05 16:26:53 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
static char *ft_checks(char *s, char *d, size_t n)
{
size_t i;
i = 0;
if (d < s)
{
while (i < n)
{
d[i] = s[i];
i++;
}
}
else
{
i = n;
while (i > 0)
{
i--;
d[i] = s[i];
}
}
return (d);
}
void *ft_memmove(void *dest, const void *src, size_t n)
{
char *d;
char *s;
if (!dest && !src)
return (NULL);
d = (char *)dest;
s = (char *)src;
ft_checks(s, d, n);
return (dest);
}