Lines Matching refs:hash

70 #define TDB_HASH_TOP(hash) (FREELIST_TOP + (BUCKET(hash)+1)*sizeof(tdb_off))  argument
105 #define BUCKET(hash) ((hash) % tdb->header.hash_size) argument
930 static tdb_off tdb_find(TDB_CONTEXT *tdb, TDB_DATA key, uint32_t hash, argument
936 if (ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1)
944 if (!TDB_DEAD(r) && hash==r->full_hash && key.dsize==r->key_len) {
958 static tdb_off tdb_find_lock_hash(TDB_CONTEXT *tdb, TDB_DATA key, uint32_t hash, int locktype, argument
963 if (tdb_lock(tdb, BUCKET(hash), locktype) == -1)
965 if (!(rec_ptr = tdb_find(tdb, key, hash, rec)))
966 tdb_unlock(tdb, BUCKET(hash), locktype);
1001 static int tdb_update_hash(TDB_CONTEXT *tdb, TDB_DATA key, uint32_t hash, TDB_DATA dbuf) argument
1007 if (!(rec_ptr = tdb_find(tdb, key, hash, &rec)))
1041 uint32_t hash; local
1044 hash = tdb->hash_fn(&key);
1045 if (!(rec_ptr = tdb_find_lock_hash(tdb,key,hash,F_RDLCK,&rec)))
1061 static int tdb_exists_hash(TDB_CONTEXT *tdb, TDB_DATA key, uint32_t hash) argument
1065 if (tdb_find_lock_hash(tdb, key, hash, F_RDLCK, &rec) == 0)
1156 for (; tlock->hash < tdb->header.hash_size; tlock->hash++) {
1186 if (!tlock->off && tlock->hash != 0) {
1189 for (;tlock->hash < tdb->header.hash_size;tlock->hash++) {
1190 if (0 != *(uint32_t *)(TDB_HASH_TOP(tlock->hash) + (unsigned char *)tdb->map_ptr)) {
1194 if (tlock->hash == tdb->header.hash_size) {
1198 if (ofs_read(tdb, TDB_HASH_TOP(tlock->hash), &off) == 0 &&
1205 if (tdb_lock(tdb, tlock->hash, F_WRLCK) == -1)
1210 if (ofs_read(tdb, TDB_HASH_TOP(tlock->hash),
1252 tdb_unlock(tdb, tlock->hash, F_WRLCK);
1260 if (tdb_unlock(tdb, tlock->hash, F_WRLCK) != 0)
1293 if (tdb_unlock(tdb, tl.hash, F_WRLCK) != 0)
1304 if (tdb_unlock(tdb, tl.hash, F_WRLCK) != 0) {
1338 tdb->travlocks.off = tdb->travlocks.hash = 0;
1345 if (tdb_unlock(tdb, BUCKET(tdb->travlocks.hash), F_WRLCK) != 0)
1360 if (tdb_lock(tdb,tdb->travlocks.hash,F_WRLCK))
1369 if (tdb_unlock(tdb, tdb->travlocks.hash, F_WRLCK) != 0)
1382 tdb->travlocks.hash = BUCKET(rec.full_hash);
1388 oldhash = tdb->travlocks.hash;
1397 if (tdb_unlock(tdb, tdb->travlocks.hash, F_WRLCK) != 0)
1407 static int tdb_delete_hash(TDB_CONTEXT *tdb, TDB_DATA key, uint32_t hash) argument
1413 if (!(rec_ptr = tdb_find_lock_hash(tdb, key, hash, F_WRLCK, &rec)))
1423 uint32_t hash = tdb->hash_fn(&key); local
1424 return tdb_delete_hash(tdb, key, hash);
1435 uint32_t hash; local
1441 hash = tdb->hash_fn(&key);
1442 if (tdb_lock(tdb, BUCKET(hash), F_WRLCK) == -1)
1447 if (tdb_exists_hash(tdb, key, hash)) {
1453 if (tdb_update_hash(tdb, key, hash, dbuf) == 0)
1469 tdb_delete_hash(tdb, key, hash);
1488 if (ofs_read(tdb, TDB_HASH_TOP(hash), &rec.next) == -1)
1493 rec.full_hash = hash;
1499 || ofs_write(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) {
1505 tdb_unlock(tdb, BUCKET(hash), F_WRLCK);