Licensing Information
Open Source Used In Cisco FXOS 1.1(4) 968
/* return the number traversed */
return count;
fail:
tdb_unlock(tdb, BUCKET(h));
return -1;
}
/* find the first entry in the database and return its key */
TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb)
{
tdb_off offset, rec_ptr;
struct list_struct rec;
unsigned hash;
TDB_DATA ret;
if (tdb == NULL) {
#ifdef TDB_DEBUG
printf("tdb_firstkey() called with null context\n");
#endif
return null_data;
}
/* look for a non-empty hash chain */
for (hash = 0, rec_ptr = 0;
hash < tdb->header.hash_size;
hash++) {
/* 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) {