blob: 076bdac7d711e5f33721d1f11ac9e5c69c1dc1cf [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 * Copyright (C) 2002 Manuel Novoa III
3 * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
4 *
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 */
7
8/* No wide analog. */
9
10#include "_string.h"
11
12void *memccpy(void * __restrict s1, const void * __restrict s2, int c, size_t n)
13{
14 register char *r1 = s1;
15 register const char *r2 = s2;
16
17 while (n-- && (((unsigned char)(*r1++ = *r2++)) != ((unsigned char) c)));
18
19 return (n == (size_t) -1) ? NULL : r1;
20}
21libc_hidden_def(memccpy)