Licensing Information
Open Source Used In Cisco FXOS 1.1(4) 970
tdb_lock(tdb, hbucket);
/* read in the hash top */
if (ofs_read(tdb, offset, &rec_ptr) == -1) {
tdb_unlock(tdb, hbucket);
return null_data;
}
}
/* Read the record. */
if (rec_read(tdb, rec_ptr, &rec) == -1) {
tdb_unlock(tdb, hbucket);
return null_data;
}
/* allocate and read the key */
ret.dptr = tdb_alloc_read(tdb, rec_ptr + sizeof(rec), rec.key_len);
ret.dsize = rec.key_len;
tdb_unlock(tdb, hbucket);
return ret;
}
/* delete an entry in the database given a key */
int tdb_delete(TDB_CONTEXT *tdb, TDB_DATA key)
{
unsigned hash;
tdb_off offset, rec_ptr, last_ptr;
struct list_struct rec, lastrec;
char *data = NULL;
if (tdb == NULL) {
#ifdef TDB_DEBUG
printf("tdb_delete() called with null context\n");
#endif
return -1;
}
/* find which hash bucket it is in */
hash = tdb_hash(&key);
tdb_lock(tdb, BUCKET(hash));
/* find the top of the hash chain */
offset = tdb_hash_top(tdb, hash);
/* read in the hash top */
if (ofs_read(tdb, offset, &rec_ptr) == -1) {
goto fail;
}