xref: /csrg-svn/lib/libc/string/memccpy.c (revision 49952)
141958Sbostic /*-
241958Sbostic  * Copyright (c) 1990 The Regents of the University of California.
334479Sbostic  * All rights reserved.
434479Sbostic  *
541958Sbostic  * %sccs.include.redist.c%
624194Skre  */
724194Skre 
826525Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*49952Sbostic static char sccsid[] = "@(#)memccpy.c	5.8 (Berkeley) 05/30/91";
1034479Sbostic #endif /* LIBC_SCCS and not lint */
1124194Skre 
1246144Sbostic #include <sys/cdefs.h>
1341958Sbostic #include <string.h>
1424194Skre 
1541958Sbostic void *
1624194Skre memccpy(t, f, c, n)
1742447Sbostic 	void *t;
1842447Sbostic 	const void *f;
1942447Sbostic 	int c;
2041958Sbostic 	register size_t n;
2124194Skre {
2242447Sbostic 
2342447Sbostic 	if (n) {
24*49952Sbostic 		register unsigned char *tp = t;
25*49952Sbostic 		register const unsigned char *fp = f;
2642447Sbostic 		do {
27*49952Sbostic 			if ((*tp++ = *fp++) == c)
2842447Sbostic 				return (t);
2942447Sbostic 		} while (--n != 0);
3042447Sbostic 	}
3124194Skre 	return (0);
3224194Skre }
33