Licensing Information

Open Source Used In Cisco FXOS 1.1(3) 875
if (rec.magic != TDB_FREE_MAGIC) goto fail;
/* find the top of the hash chain */
offset = tdb_hash_top(tdb, hash);
/* read in the hash top diretcly into our next pointer */
if (ofs_read(tdb, offset, &rec.next) == -1) {
goto fail;
}
rec.key_len = key.dsize;
rec.data_len = dbuf.dsize;
rec.full_hash = hash;
rec.magic = TDB_MAGIC;
p = (char *)malloc(sizeof(rec) + key.dsize + dbuf.dsize);
if (!p) {
tdb->ecode = TDB_ERR_OOM;
goto fail;
}
memcpy(p, &rec, sizeof(rec));
memcpy(p+sizeof(rec), key.dptr, key.dsize);
memcpy(p+sizeof(rec)+key.dsize, dbuf.dptr, dbuf.dsize);
if (tdb_write(tdb, rec_ptr, p, sizeof(rec)+key.dsize+dbuf.dsize) == -1)
goto fail;
free(p);
p = NULL;
/* and point the top of the hash chain at it */
if (ofs_write(tdb, offset, &rec_ptr) == -1) goto fail;
tdb_unlock(tdb, BUCKET(hash));
return 0;
fail:
#if TDB_DEBUG
printf("store failed for hash 0x%08x in bucket %u\n", hash, BUCKET(hash));
#endif
if (p) free(p);
tdb_unlock(tdb, BUCKET(hash));
return -1;
}