Licensing Information
Open Source Used In Cisco FXOS 1.1(4) 967
#endif
return -1;
}
/* loop over all hash chains */
for (h = 0; h < tdb->header.hash_size; h++) {
tdb_lock(tdb, BUCKET(h));
/* read in the hash top */
offset = tdb_hash_top(tdb, h);
if (ofs_read(tdb, offset, &rec_ptr) == -1) {
goto fail;
}
/* traverse all records for this hash */
while (rec_ptr) {
if (rec_read(tdb, rec_ptr, &rec) == -1) {
goto fail;
}
/* now read the full record */
data = tdb_alloc_read(tdb, rec_ptr + sizeof(rec),
rec.key_len + rec.data_len);
if (!data) {
goto fail;
}
key.dptr = data;
key.dsize = rec.key_len;
dbuf.dptr = data + rec.key_len;
dbuf.dsize = rec.data_len;
count++;
if (fn && fn(tdb, key, dbuf, state) != 0) {
/* they want us to stop traversing */
free(data);
tdb_unlock(tdb, BUCKET(h));
return count;
}
/* a miss - drat */
free(data);
/* move to the next record */
rec_ptr = rec.next;
}
tdb_unlock(tdb, BUCKET(h));
}