ft_memmove.c 1.1 KB

12345678910111213141516171819202122232425
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_memmove.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: mazimi <mazimi@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2014/11/12 17:19:17 by mazimi #+# #+# */
  9. /* Updated: 2014/12/02 15:56:41 by mazimi ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "../libft.h"
  13. void *ft_memmove(void *dest, const void *src, size_t n)
  14. {
  15. if (dest == NULL)
  16. return (NULL);
  17. if (src <= dest)
  18. while (n--)
  19. ((unsigned char *)dest)[n] = ((unsigned char *)src)[n];
  20. else
  21. ft_memcpy(dest, src, n);
  22. return ((void *)dest);
  23. }