memcmp replacement fixes

This commit is contained in:
Kurt Zeilenga 2005-03-14 18:08:04 +00:00
parent 97e4865b91
commit d68ec7b661
2 changed files with 8 additions and 4 deletions

View File

@ -89,6 +89,11 @@ int (strncasecmp)();
else AC_MEMCPY( (d), (s), (n) ); \
} while(0)
#ifdef NEED_MEMCMP_REPLACEMENT
int (lutil_memcmp)(const void *b1, const void *b2, size_t len);
#define memcmp lutil_memcmp
#endif
#define STRLENOF(s) (sizeof(s)-1)
#endif /* _AC_STRING_H */

View File

@ -21,14 +21,13 @@
* Memory Compare
*/
int
(memcmp)(const void *v1, const void *v2, int n)
(lutil_memcmp)(const void *v1, const void *v2, size_t n)
{
if (n != 0) {
const unsigned char *s1=v1, *s2=v2;
do {
if (*s1++ != *s2++)
return (*--s1 - *--s2);
if (*s1++ != *s2++) return *--s1 - *--s2;
} while (--n != 0);
}
return (0);
return 0;
}