libft/memory/ft_memcpy.c
Raphael 905ffd4b72
refactor: only the usefull header
- Removing all 'libft.h' mention
- Using the include only on the files needed by
2025-09-01 18:45:33 +02:00

41 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 16:49:46 by rparodi #+# #+# */
/* Updated: 2025/09/01 16:41:32 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
/**
* @brief Copies memory from source to destination
*
* @param dest Pointer to the destination memory area
* @param src Pointer to the source memory area
* @param n Number of bytes to copy from src to dest
*
* @return A pointer to the destination memory area dest
*/
void *ft_memcpy(void *dest, const void *src, size_t n)
{
char *d;
const char *s;
size_t i;
i = 0;
if (!dest && !src)
return (NULL);
d = (char *)dest;
s = (char *)src;
while (i < n)
{
d[i] = s[i];
i++;
}
return ((void *)d);
}