Lines Matching refs:key
296 static uint32_t default_tdb_hash(TDB_DATA *key) in default_tdb_hash() argument
302 for (value = 0x238F13AF * key->dsize, i=0; i < key->dsize; i++) in default_tdb_hash()
303 value = (value + (key->dptr[i] << (i*5 % 24))); in default_tdb_hash()
398 static int tdb_key_eq(TDB_CONTEXT *tdb, tdb_off off, TDB_DATA key) argument
403 if (tdb_oob(tdb, off + key.dsize, 0) != 0)
407 return !memcmp(off + (char*)tdb->map_ptr, key.dptr, key.dsize);
409 while (key.dsize) {
410 len = key.dsize;
415 if (memcmp(buf, key.dptr, len) != 0)
417 key.dptr += len;
418 key.dsize -= len;
930 static tdb_off tdb_find(TDB_CONTEXT *tdb, TDB_DATA key, uint32_t hash, argument
944 if (!TDB_DEAD(r) && hash==r->full_hash && key.dsize==r->key_len) {
946 int cmp = tdb_key_eq(tdb, rec_ptr + sizeof(*r), key);
958 static tdb_off tdb_find_lock_hash(TDB_CONTEXT *tdb, TDB_DATA key, uint32_t hash, int locktype, argument
965 if (!(rec_ptr = tdb_find(tdb, key, hash, rec)))
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)))
1011 if (rec.rec_len < key.dsize + dbuf.dsize + sizeof(tdb_off)) {
1036 TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key) argument
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)
1272 TDB_DATA key, dbuf; local
1289 key.dptr = tdb_alloc_read(tdb, tl.off + sizeof(rec),
1291 if (!key.dptr) {
1299 key.dsize = rec.key_len;
1300 dbuf.dptr = key.dptr + rec.key_len;
1308 if (fn && fn(tdb, key, dbuf, private)) {
1316 SAFE_FREE(key.dptr);
1319 SAFE_FREE(key.dptr);
1332 TDB_DATA key; local
1343 key.dsize = rec.key_len;
1344 key.dptr =tdb_alloc_read(tdb,tdb->travlocks.off+sizeof(rec),key.dsize);
1347 return key;
1354 TDB_DATA key = tdb_null; local
1393 key.dsize = rec.key_len;
1394 key.dptr = tdb_alloc_read(tdb, tdb->travlocks.off+sizeof(rec),
1395 key.dsize);
1403 return key;
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)))
1421 int tdb_delete(TDB_CONTEXT *tdb, TDB_DATA key) argument
1423 uint32_t hash = tdb->hash_fn(&key);
1424 return tdb_delete_hash(tdb, key, hash);
1432 int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag) argument
1441 hash = tdb->hash_fn(&key);
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);
1474 if (!(p = (char *)talloc_size(tdb, key.dsize + dbuf.dsize))) {
1479 memcpy(p, key.dptr, key.dsize);
1481 memcpy(p+key.dsize, dbuf.dptr, dbuf.dsize);
1484 if (!(rec_ptr = tdb_allocate(tdb, key.dsize + dbuf.dsize, &rec)))
1491 rec.key_len = key.dsize;
1498 || tdb_write(tdb, rec_ptr+sizeof(rec), p, key.dsize+dbuf.dsize)==-1