-tdb_off_t hash_off(struct tdb_context *tdb, uint64_t list)
-{
- return tdb->header.v.hash_off
- + ((list & ((1ULL << tdb->header.v.hash_bits) - 1))
- * sizeof(tdb_off_t));
-}
-
-/* Returns 0 if the entry is a zero (definitely not a match).
- * Returns a valid entry offset if it's a match. Fills in rec.
- * Otherwise returns TDB_OFF_ERR: keep searching. */
-static tdb_off_t entry_matches(struct tdb_context *tdb,
- uint64_t list,
- uint64_t hash,
- const struct tdb_data *key,
- struct tdb_used_record *rec)
-{
- tdb_off_t off;
- uint64_t keylen;
- const unsigned char *rkey;
-
- list &= ((1ULL << tdb->header.v.hash_bits) - 1);
-
- off = tdb_read_off(tdb, tdb->header.v.hash_off
- + list * sizeof(tdb_off_t));
- if (off == 0 || off == TDB_OFF_ERR)
- return off;
-
-#if 0 /* FIXME: Check other bits. */
- unsigned int bits, bitmask, hoffextra;
- /* Bottom three bits show how many extra hash bits. */
- bits = (off & ((1 << TDB_EXTRA_HASHBITS_NUM) - 1)) + 1;
- bitmask = (1 << bits)-1;
- hoffextra = ((off >> TDB_EXTRA_HASHBITS_NUM) & bitmask);
- uint64_t hextra = hash >> tdb->header.v.hash_bits;
- if ((hextra & bitmask) != hoffextra)
- return TDB_OFF_ERR;
- off &= ~...;
-#endif
-
- if (tdb_read_convert(tdb, off, rec, sizeof(*rec)) == -1)
- return TDB_OFF_ERR;
-
- /* FIXME: check extra bits in header! */
- keylen = rec_key_length(rec);
- if (keylen != key->dsize)
- return TDB_OFF_ERR;
-
- rkey = tdb_access_read(tdb, off + sizeof(*rec), keylen, false);
- if (!rkey)
- return TDB_OFF_ERR;
- if (memcmp(rkey, key->dptr, keylen) != 0)
- off = TDB_OFF_ERR;
- tdb_access_release(tdb, rkey);
- return off;
-}
-
-/* FIXME: Optimize? */
-static void unlock_lists(struct tdb_context *tdb,
- tdb_off_t list, tdb_len_t num,
- int ltype)
-{
- tdb_off_t i;
-
- for (i = list; i < list + num; i++)
- tdb_unlock_list(tdb, i, ltype);
-}
-
-/* FIXME: Optimize? */
-static int lock_lists(struct tdb_context *tdb,
- tdb_off_t list, tdb_len_t num,
- int ltype)