Licensing Information

Open Source Used In Cisco FXOS 1.1(3) 862
newrec.next = rec.next;
newrec.magic = TDB_FREE_MAGIC;
rec.rec_len = length;
rec.next = rec_ptr + sizeof(rec) + rec.rec_len;

if (rec_write(tdb, rec.next, &newrec) == -1) {
goto fail;
}
if (rec_write(tdb, rec_ptr, &rec) == -1) {
goto fail;
}
}
/* remove it from the list */
if (last_ptr == 0) {
offset = FREELIST_TOP;
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;
}
}
/* all done - return the new record offset */
tdb_unlock(tdb, -1);
return rec_ptr;
}
/* move to the next record */
lastrec = rec;
last_ptr = rec_ptr;
rec_ptr = rec.next;
}
/* we didn't find enough space. See if we can expand the
 database and if we can then try again */
if (tdb_expand(tdb, length + sizeof(rec)) == 0) goto again;
fail:
#if TDB_DEBUG
printf("tdb_allocate failed for size %u\n", length);
#endif