]> pd.if.org Git - pdclib/blob - functions/string/memcmp.c
Added some of <string.h>.
[pdclib] / functions / string / memcmp.c
1 /* $Id$ */
2
3 /* Release $Name$ */
4
5 /* memcmp( const void *, const void *, size_t )
6
7    This file is part of the Public Domain C Library (PDCLib).
8    Permission is granted to use, modify, and / or redistribute at will.
9 */
10
11 #include <string.h>
12
13 int memcmp( const void * s1, const void * s2, size_t n )
14 {
15     const unsigned char * p1 = (const unsigned char *) s1;
16     const unsigned char * p2 = (const unsigned char *) s2;
17     while ( n-- )
18     {
19         if ( *p1 != *p2 )
20         {
21             return *p2 - *p1;
22         }
23         ++p1;
24         ++p2;
25     }
26     return 0;
27 }