Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8622 | Boppan | 1 | /* memchr( const void *, int, size_t ) |
2 | |||
3 | This file is part of the Public Domain C Library (PDCLib). |
||
4 | Permission is granted to use, modify, and / or redistribute at will. |
||
5 | */ |
||
6 | |||
7 | #include |
||
8 | |||
9 | void * memchr( const void * s, int c, size_t n ) |
||
10 | { |
||
11 | const unsigned char * p = ( const unsigned char * ) s; |
||
12 | |||
13 | while ( n-- ) |
||
14 | { |
||
15 | if ( *p == ( unsigned char ) c ) |
||
16 | { |
||
17 | return ( void * ) p; |
||
18 | } |
||
19 | |||
20 | ++p; |
||
21 | } |
||
22 | |||
23 | return NULL; |
||
24 | } |