-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcpy.c
37 lines (34 loc) · 1.44 KB
/
ft_memcpy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pix <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/17 14:32:38 by stales #+# #+# */
/* Updated: 2022/04/04 02:56:08 by pix ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Copies n bytes from memory area src to memory area dest.
* The memory areas must not overlap.
*
* @param dest Destination memory area
* @param src Source memory area
* @param n Number of bytes to copy
*
* @return (void *) The ft_memcpy() function returns a pointer to dest.
*/
void *ft_memcpy(void *dest, const void *src, t_size n)
{
unsigned char *tdst;
unsigned char *tsrc;
if (!dest && !src)
return (dest);
tsrc = (unsigned char *)src;
tdst = (unsigned char *)dest;
while (n--)
*tdst++ = *tsrc++;
return (dest);
}