Licensing Information
Open Source Used In Cisco FXOS 1.1(3) 867
return null_data;
}
/* find which hash bucket it is in */
hash = tdb_hash(&key);
tdb_lock(tdb, BUCKET(hash));
rec_ptr = tdb_find(tdb, key, hash, &rec);
if (rec_ptr) {
ret.dptr = tdb_alloc_read(tdb,
rec_ptr + sizeof(rec) + rec.key_len,
rec.data_len);
ret.dsize = rec.data_len;
}
tdb_unlock(tdb, BUCKET(hash));
return ret;
}
/* check if an entry in the database exists
note that 1 is returned if the key is found and 0 is returned if not found
this doesn't match the conventions in the rest of this module, but is
compatible with gdbm
*/
int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key)
{
unsigned hash;
tdb_off rec_ptr;
struct list_struct rec;
if (tdb == NULL) {
#ifdef TDB_DEBUG
printf("tdb_exists() called with null context\n");
#endif
return 0;
}
/* find which hash bucket it is in */
hash = tdb_hash(&key);
tdb_lock(tdb, BUCKET(hash));
rec_ptr = tdb_find(tdb, key, hash, &rec);
tdb_unlock(tdb, BUCKET(hash));
return rec_ptr != 0;
}