Subversion Repositories Kolibri OS

Rev

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

  1. /* memcmp( const void *, const void *, 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. int memcmp( const void * s1, const void * s2, size_t n )
  10. {
  11.     const unsigned char * p1 = ( const unsigned char * ) s1;
  12.     const unsigned char * p2 = ( const unsigned char * ) s2;
  13.  
  14.     while ( n-- )
  15.     {
  16.         if ( *p1 != *p2 )
  17.         {
  18.             return *p1 - *p2;
  19.         }
  20.  
  21.         ++p1;
  22.         ++p2;
  23.     }
  24.  
  25.     return 0;
  26. }
  27.