Licensing Information
Open Source Used In Cisco FXOS 1.1(4) 971
last_ptr = 0;
/* keep looking until we find the right record */
while (rec_ptr) {
if (rec_read(tdb, rec_ptr, &rec) == -1) {
goto fail;
}
if (hash == rec.full_hash && key.dsize == rec.key_len) {
/* a very likely hit - read the record and full key */
data = tdb_alloc_read(tdb, rec_ptr + sizeof(rec),
rec.key_len);
if (!data) {
goto fail;
}
if (memcmp(key.dptr, data, key.dsize) == 0) {
/* a definite match - delete it */
if (last_ptr == 0) {
offset = tdb_hash_top(tdb, hash);
if (ofs_write(tdb, offset, &rec.next) == -1) {
goto fail;
}
} else {
lastrec.next = rec.next;
if (rec_write(tdb, last_ptr, &lastrec) == -1) {
goto fail;
}
}
tdb_unlock(tdb, BUCKET(hash));
tdb_lock(tdb, -1);
/* and recover the space */
offset = FREELIST_TOP;
if (ofs_read(tdb, offset, &rec.next) == -1) {
goto fail2;
}
rec.magic = TDB_FREE_MAGIC;
if (rec_write(tdb, rec_ptr, &rec) == -1) {
goto fail2;
}
if (ofs_write(tdb, offset, &rec_ptr) == -1) {
goto fail2;
}
/* yipee - all done */
free(data);
tdb_unlock(tdb, -1);