Author: quozl Date: Thu Jul 14 04:05:00 2011 New Revision: 2353 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2353
Log: memcmp version from multicast-nand moved into library, Mitch identified it as better than the one that was there.
Modified: clients/lib/mem.c
Modified: clients/lib/mem.c ============================================================================== --- clients/lib/mem.c Thu Jul 14 01:28:41 2011 (r2352) +++ clients/lib/mem.c Thu Jul 14 04:05:00 2011 (r2353) @@ -17,10 +17,13 @@ }
int -memcmp(void *s1, void *s2, int len) +memcmp(const void *s1, const void *s2, size_t n) { - for (; len--; ++s1, ++s2) - if (*(unsigned char *)s1 != *(unsigned char *)s2) - return *(unsigned char *)s1 - *(unsigned char *)s2; + int diff; + while (n--) { + diff = *(unsigned char *)s1++ - *(unsigned char *)s2++; + if (diff) + return (diff < 0) ? -1 : 1; + } return 0; }
openfirmware@openfirmware.info