Licensing Information

Open Source Used In Cisco FXOS 1.1(3) 856
if (tdb->locked[list+1] == 0) {
#if TDB_DEBUG
printf("not locked %d\n", list);
#endif
tdb->ecode = TDB_ERR_LOCK;
return -1;
}
if (tdb->locked[list+1] == 1) {
if (tdb_brlock(tdb, LIST_LOCK_BASE + 4*list, LOCK_CLEAR,
 F_WRLCK, F_SETLKW) != 0) {
return -1;
}
}
tdb->locked[list+1]--;
return 0;
}
/* the hash algorithm - turn a key into an integer
This is based on the hash agorithm from gdbm */
static unsigned tdb_hash(TDB_DATA *key)
{
unsigned value;/* Used to compute the hash value. */
unsigned i;/* Used to cycle through random values. */
/* Set the initial value from the key size. */
value = 0x238F13AF * key->dsize;
for (i=0; i < key->dsize; i++) {
value = (value + (key->dptr[i] << (i*5 % 24)));
}
value = (1103515243 * value + 12345);
return value;
}
/* find the top of the hash chain for an open database */
static tdb_off tdb_hash_top(TDB_CONTEXT *tdb, unsigned hash)
{
tdb_off ret;
hash = BUCKET(hash);
ret = FREELIST_TOP + (hash+1)*sizeof(tdb_off);
return ret;
}
/* check for an out of bounds access - if it is out of bounds then
see if the database has been expanded by someone else and expand