-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_memccpy.c
31 lines (28 loc) · 1.21 KB
/
ft_memccpy.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oadhesiv <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/04 18:28:54 by oadhesiv #+# #+# */
/* Updated: 2019/06/01 15:46:05 by oadhesiv ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
void *ptr;
size_t copy_len;
if (!dst || !src || !n)
return ((void *)0);
ptr = ft_memchr(src, c, n);
if (ptr)
{
copy_len = ptr - src + 1;
ft_memcpy(dst, src, copy_len);
return (dst + copy_len);
}
ft_memcpy(dst, src, n);
return ((void*)0);
}