Licensing Information

Open Source Used In Cisco FXOS 1.1(4) 959
tdb->map_ptr = NULL;
}
#endif
tdb->map_size += length;
if (tdb->fd == -1) {
tdb->map_ptr = realloc(tdb->map_ptr, tdb->map_size);
}
/* write it out */
if (rec_write(tdb, tdb->map_size - length, &rec) == -1) {
goto fail;
}
/* link it into the free list */
ptr = tdb->map_size - length;
if (ofs_write(tdb, offset, &ptr) == -1) goto fail;
#if HAVE_MMAP
if (tdb->fd != -1) {
tdb->map_ptr = (void *)mmap(NULL, tdb->map_size,
PROT_READ|PROT_WRITE,
MAP_SHARED | MAP_FILE, tdb->fd, 0);
}
#endif
tdb_unlock(tdb, -1);
return 0;
fail:
tdb_unlock(tdb,-1);
return -1;
}
/* allocate some space from the free list. The offset returned points
to a unconnected list_struct within the database with room for at
least length bytes of total data
0 is returned if the space could not be allocated
*/
static tdb_off tdb_allocate(TDB_CONTEXT *tdb, tdb_len length)
{
tdb_off offset, rec_ptr, last_ptr;
struct list_struct rec, lastrec, newrec;
tdb_lock(tdb, -1);