-int yf::memcmp2(const void *buf1, int len1,
- const void *buf2, int len2)
-{
- int d = len1 - len2;
-
- // compare buffer (common length)
- int c = memcmp(buf1, buf2, d > 0 ? len2 : len1);
- if (c > 0)
- return 1;
- else if (c < 0)
- return -1;
-
- // compare (remaining bytes)
- if (d > 0)
- return 1;
- else if (d < 0)
- return -1;
- return 0;
-}