static void mdb_default_cmp(MDB_txn *txn, MDB_dbi dbi);
-static MDB_cmp_func memncmp, memnrcmp, intcmp;
+static MDB_cmp_func memncmp, memnrcmp, intcmp, cintcmp;
#ifdef _WIN32
static SECURITY_DESCRIPTOR mdb_null_sd;
free(env);
}
+/* only for aligned ints */
static int
intcmp(const MDB_val *a, const MDB_val *b)
{
}
}
+/* ints must always be the same size */
+static int
+cintcmp(const MDB_val *a, const MDB_val *b)
+{
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned char *u, *c;
+ int x;
+
+ u = a->mv_data + a->mv_size;
+ c = b->mv_data + a->mv_size;
+ while(u > (unsigned char *)a->mv_data) {
+ x = *--u - *--c;
+ if (x) break;
+ }
+ return x;
+#else
+ return memcmp(a->mv_data, b->mv_data, a->mv_size);
+#endif
+}
+
static int
memncmp(const MDB_val *a, const MDB_val *b)
{
if (rc > 0) { /* Found entry is less than the key. */
i++; /* Skip to get the smallest entry larger than key. */
+ if (!IS_LEAF2(mp))
+ node = NODEPTR(mp, i);
}
if (exactp)
*exactp = (rc == 0);
static void
mdb_default_cmp(MDB_txn *txn, MDB_dbi dbi)
{
- if (txn->mt_dbs[dbi].md_flags & (MDB_REVERSEKEY
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- |MDB_INTEGERKEY
-#endif
- ))
+ if (txn->mt_dbs[dbi].md_flags & MDB_REVERSEKEY)
txn->mt_dbxs[dbi].md_cmp = memnrcmp;
+ else if (txn->mt_dbs[dbi].md_flags & MDB_INTEGERKEY)
+ txn->mt_dbxs[dbi].md_cmp = cintcmp;
else
txn->mt_dbxs[dbi].md_cmp = memncmp;
if (txn->mt_dbs[dbi].md_flags & MDB_DUPFIXED)
txn->mt_dbxs[dbi].md_dcmp = intcmp;
else
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- txn->mt_dbxs[dbi].md_dcmp = memnrcmp;
-#else
- txn->mt_dbxs[dbi].md_dcmp = memncmp;
-#endif
+ txn->mt_dbxs[dbi].md_dcmp = cintcmp;
} else if (txn->mt_dbs[dbi].md_flags & MDB_REVERSEDUP) {
txn->mt_dbxs[dbi].md_dcmp = memnrcmp;
} else {