Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  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 <string.h>
  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. }