Licensing Information

Open Source Used In Cisco FXOS 1.1(4) 960
again:
last_ptr = 0;
offset = FREELIST_TOP;
/* read in the freelist top */
if (ofs_read(tdb, offset, &rec_ptr) == -1) {
goto fail;
}
/* keep looking until we find a freelist record that is big
enough */
while (rec_ptr) {
if (tdb_read(tdb, rec_ptr, (char *)&rec, sizeof(rec)) == -1) {
goto fail;
}
if (rec.magic != TDB_FREE_MAGIC) {
#if TDB_DEBUG
printf("bad magic 0x%08x in free list\n", rec.magic);
#endif
goto fail;
}
if (rec.rec_len >= length) {
/* found it - now possibly split it up */
if (rec.rec_len > length + MIN_REC_SIZE) {
length = (length + TDB_ALIGN) & ~(TDB_ALIGN-1);
newrec.rec_len = rec.rec_len - (sizeof(rec) + length);
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;