Commit | Line | Data |
---|---|---|
556da4c5 KB |
1 | /*- |
2 | * Copyright (c) 1990 The Regents of the University of California. | |
317e5946 KB |
3 | * All rights reserved. |
4 | * | |
556da4c5 | 5 | * %sccs.include.redist.c% |
7bbdb8c5 RE |
6 | */ |
7 | ||
2ce81398 | 8 | #if defined(LIBC_SCCS) && !defined(lint) |
25140ba2 | 9 | static char sccsid[] = "@(#)memccpy.c 5.6 (Berkeley) %G%"; |
317e5946 | 10 | #endif /* LIBC_SCCS and not lint */ |
7bbdb8c5 | 11 | |
556da4c5 KB |
12 | #include <string.h> |
13 | #include <sys/stdc.h> | |
7bbdb8c5 | 14 | |
556da4c5 | 15 | void * |
7bbdb8c5 | 16 | memccpy(t, f, c, n) |
25140ba2 KB |
17 | void *t; |
18 | const void *f; | |
19 | int c; | |
556da4c5 | 20 | register size_t n; |
7bbdb8c5 | 21 | { |
25140ba2 KB |
22 | |
23 | if (n) { | |
24 | register unsigned char *t; | |
25 | register const unsigned char *f; | |
26 | register unsigned char ch = c; | |
27 | ||
28 | do { | |
29 | if ((*t++ = *f++) == c) | |
30 | return (t); | |
31 | } while (--n != 0); | |
32 | } | |
7bbdb8c5 RE |
33 | return (0); |
34 | } |