memchr.c (165903) | memchr.c (188080) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#if defined(LIBC_SCCS) && !defined(lint) 34static char sccsid[] = "@(#)memchr.c 8.1 (Berkeley) 6/4/93"; 35#endif /* LIBC_SCCS and not lint */ 36#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#if defined(LIBC_SCCS) && !defined(lint) 34static char sccsid[] = "@(#)memchr.c 8.1 (Berkeley) 6/4/93"; 35#endif /* LIBC_SCCS and not lint */ 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/lib/libc/string/memchr.c 165903 2007-01-09 00:28:16Z imp $"); | 37__FBSDID("$FreeBSD: head/lib/libc/string/memchr.c 188080 2009-02-03 17:58:20Z danger $"); |
38 39#include <string.h> 40 41void * | 38 39#include <string.h> 40 41void * |
42memchr(s, c, n) 43 const void *s; 44 unsigned char c; 45 size_t n; | 42memchr(const void *s, unsigned char c, size_t n) |
46{ 47 if (n != 0) { 48 const unsigned char *p = s; 49 50 do { 51 if (*p++ == c) 52 return ((void *)(p - 1)); 53 } while (--n != 0); 54 } 55 return (NULL); 56} | 43{ 44 if (n != 0) { 45 const unsigned char *p = s; 46 47 do { 48 if (*p++ == c) 49 return ((void *)(p - 1)); 50 } while (--n != 0); 51 } 52 return (NULL); 53} |