bcompare.c 349 B

12345678910111213141516171819202122
  1. #include <db.h>
  2. /*
  3. * btree compare algorithm
  4. *
  5. * @a: entry
  6. * @b: entry
  7. *
  8. * return -1,0,<+diff> if a is lower, equal or greater than b
  9. */
  10. __attribute__((pure)) int compare(const DBT * restrict a, const DBT * restrict b)
  11. {
  12. size_t *v1 = a->data;
  13. size_t *v2 = b->data;
  14. if (*v1 > *v2)
  15. return -1;
  16. if (*v1 == *v2)
  17. return 0;
  18. return 1;
  19. }