src/lib/common/string.c
/// Compare two memory areas
///
/// The memcmp() function compares the first \a n bytes of the memory areas \a
/// s1 and \a s2.  It returns an integer less than, equal to, or greater than
/// zero if \a s1 is found, respectively, to be less than, to match, or be
/// greater than \a s2.
Compare two memory areas
The memcmp() function compares the first \a n bytes of the memory areas \a
s1 and \a s2.  It returns an integer less than, equal to, or greater than
zero if \a s1 is found, respectively, to be less than, to match, or be
greater than \a s2.
Compare two memory areas The memcmp () function compares the first \ a n bytes of the memory areas \ a s1 and \ a s2 . It returns an integer less than equal to or greater than zero if \ a s1 is found respectively to be less than to match or be greater than \ a s2 .
int
memcmp(const void* s1, const void* s2, size_t n) 
{
    unsigned char *p1, *p2;
    int rc;
    p1 = (unsigned char*) s1;
    p2 = (unsigned char*) s2;
    if (s1 == s2) {
        rc = 0;
    } else {
        while (n && (*p1 == *p2)) {
            n--;
            p1++; 
            p2++;
        }
        if (n == 0) {
            rc = 0;
        } else {
            rc = (*p1 - *p2);
        }
    }
    return rc;
}
int memcmp ( const void * s1 , const void * s2 , size_t n ) { unsigned char * p1 , * p2 ; int rc ; p1 = ( unsigned char * ) s1 ; p2 = ( unsigned char * ) s2 ; if ( s1 == s2 ) { rc = 0 ; } else { while ( n && ( * p1 == * p2 ) ) { n -- ; p1 ++ ; p2 ++ ; } if ( n == 0 ) { rc = 0 ; } else { rc = ( * p1 - * p2 ) ; } } return rc ; }
Compare two memory areas
The memcmp() function compares the first \a n bytes of the memory areas \a
s1 and \a s2.
Compare two memory areas The memcmp () function compares the first \ a n bytes of the memory areas \ a s1 and \ a s2 .