41 lines
1.4 KiB
C
41 lines
1.4 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_memcpy.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/11/07 16:49:46 by rparodi #+# #+# */
|
|
/* Updated: 2024/10/31 17:57:31 by rparodi ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.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);
|
|
}
|