Licensing Information
Open Source Used In Cisco FXOS 1.1(3) 870
/* find the top of the hash chain */
offset = tdb_hash_top(tdb, hash);
tdb_lock(tdb, BUCKET(hash));
/* read in the hash top */
if (ofs_read(tdb, offset, &rec_ptr) == -1) {
goto fail;
}
if (rec_ptr) break;
tdb_unlock(tdb, BUCKET(hash));
}
if (rec_ptr == 0) return null_data;
/* we've found a non-empty chain, now read the record */
if (rec_read(tdb, rec_ptr, &rec) == -1) {
goto fail;
}
/* allocate and read the key space */
ret.dptr = tdb_alloc_read(tdb, rec_ptr + sizeof(rec), rec.key_len);
ret.dsize = rec.key_len;
tdb_unlock(tdb, BUCKET(hash));
return ret;
fail:
tdb_unlock(tdb, BUCKET(hash));
return null_data;
}
/* find the next entry in the database, returning its key */
TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key)
{
unsigned hash, hbucket;
tdb_off rec_ptr, offset;
struct list_struct rec;
TDB_DATA ret;
if (tdb == NULL) {
#ifdef TDB_DEBUG
printf("tdb_nextkey() called with null context\n");
#endif
return null_data;
}