/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memmove.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/22 15:17:21 by narnaud #+# #+# */ /* Updated: 2022/03/24 09:22:49 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "../libft.h" void *ft_memmove(void *dst, const void *src, size_t n) { size_t i; unsigned char *ptr_dst; unsigned char *ptr_src; ptr_dst = (unsigned char *)dst; ptr_src = (unsigned char *)src; i = 0; if (!dst && !src) return (NULL); if (ptr_src < ptr_dst) while (++i <= n) ptr_dst[n - i] = ptr_src[n - i]; else while (n--) *(ptr_dst++) = *(ptr_src++); return (dst); }