]> pd.if.org Git - pdclib/blob - functions/string/memchr.c
6a09649903787a88a28640159a7e6bb87d16e95d
[pdclib] / functions / string / memchr.c
1 // ----------------------------------------------------------------------------
2 // $Id$
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
7
8 #include <__size_t.h>
9 #include <__NULL.h>
10
11 void * memchr( const void * src, int c, size_t n )
12 {
13     const unsigned char * p = (const unsigned char *) src;
14     while ( n-- )
15     {
16         if ( *p == (unsigned char) c )
17         {
18             return (void *) p;
19         }
20         ++p;
21     }
22     return NULL;
23 }