- /* Free is mostly empty... */
- newdb.zhdr.zone_bits = INITIAL_ZONE_BITS;
- memset(newdb.free, 0, sizeof(newdb.free));
-
- /* Create the single free entry. */
- newdb.frec.magic_and_meta = TDB_FREE_MAGIC | INITIAL_ZONE_BITS;
- newdb.frec.data_len = (sizeof(newdb.frec)
- - sizeof(struct tdb_used_record)
- + sizeof(newdb.space));
-
- /* Add it to the correct bucket. */
- bucket = size_to_bucket(INITIAL_ZONE_BITS, newdb.frec.data_len);
- newdb.free[bucket] = offsetof(struct new_database, frec);
- newdb.frec.next = newdb.frec.prev = 0;
-
- /* Clear free space to keep valgrind happy, and avoid leaking stack. */
- memset(newdb.space, 0, sizeof(newdb.space));
-
- /* Tailer contains maximum number of free_zone bits. */
- newdb.tailer = INITIAL_ZONE_BITS;
+ /* Free is empty. */
+ newdb.hdr.free_table = offsetof(struct new_database, ftable);
+ memset(&newdb.ftable, 0, sizeof(newdb.ftable));
+ set_header(NULL, &newdb.ftable.hdr, TDB_FTABLE_MAGIC, 0,
+ sizeof(newdb.ftable) - sizeof(newdb.ftable.hdr),
+ sizeof(newdb.ftable) - sizeof(newdb.ftable.hdr), 0);