<commit_before>/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_memmove.c                                       :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: aviala <<EMAIL>>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2013/11/22 13:53:40 by aviala            #+#    #+#             */
/*   Updated: 2013/11/27 10:23:47 by aviala           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <string.h>
#include "libft.h"

void	*ft_memmove(void *dest, const void *src, size_t n)
{
	unsigned char		*pdst;
	const unsigned char	*psrc;
	size_t				i;
	unsigned char		*tmp;

	if (dest == 0 || src == 0)
		return (0);
	pdst = dest;
	psrc = src;
	tmp = ft_memalloc(n);

	if (dest != src && n != 0)
	{
		i = 0;
		if (psrc < pdst)
		{
			while (i++ < n)
			pdst[n - i - 1] = psrc[n - i - 1];
		}
		else
		{
			while (i++ < n)
				pdst[i] = psrc[i];
		}
	}
	return ((void *)pdst);
}
<commit_msg>Fixing memmove to fit needs.<commit_after>/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_memmove.c                                       :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: aviala <<EMAIL>>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2013/11/22 13:53:40 by aviala            #+#    #+#             */
/*   Updated: 2013/11/27 10:53:30 by aviala           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <string.h>
#include "libft.h"

void	*ft_memmove(void *s1, const void *s2, size_t n)
{
	void	*tmp;

	if (s1 == NULL || s2 == NULL)
		return (NULL);
	if ((tmp = ft_memalloc(n)) == NULL)
		return (NULL);
	ft_memcpy(tmp, s2, n);
	ft_memcpy(s1, tmp, n);
	ft_memdel(&tmp);
	return ((void *)s1);
}

{'fraction_non_alphanumeric': 0.27484709480122327, 'fraction_numerical': 0.026758409785932722, 'mean_word_length': 1.0099846390168972, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6456793', 'n_tokens_mistral': 829, 'n_tokens_neox': 732, 'n_words': 138}