You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
286 B

  1. /* Public domain. */
  2. #include <stddef.h>
  3. int
  4. memcmp (const void *str1, const void *str2, size_t count)
  5. {
  6. const unsigned char *s1 = str1;
  7. const unsigned char *s2 = str2;
  8. while (count-- > 0)
  9. {
  10. if (*s1++ != *s2++)
  11. return s1[-1] < s2[-1] ? -1 : 1;
  12. }
  13. return 0;
  14. }