- zhdr.zone_bits = zone_bits;
- num_buckets = BUCKETS_FOR_ZONE(zone_bits);
-
- /* Expand the file by more than we need right now. */
- expand = 1ULL << zone_bits;
- if (expand > overhead(zone_bits) + (wanted << TDB_COMFORT_FACTOR_BITS))
- expand = overhead(zone_bits)
- + (wanted << TDB_COMFORT_FACTOR_BITS);
-
- if (tdb->methods->expand_file(tdb, expand) == -1)
- goto fail;
-
- /* Write new zone header (at old end). */
- off = old_size;
- if (tdb_write_convert(tdb, off, &zhdr, sizeof(zhdr)) == -1)
- goto fail;
-
- /* Now write empty buckets. */
- off += sizeof(zhdr);
- if (zero_out(tdb, off, (num_buckets+1) * sizeof(tdb_off_t)) == -1)
- goto fail;
- off += (num_buckets+1) * sizeof(tdb_off_t);
-
- /* Now add the rest as our free record. */
- if (add_free_record(tdb, zone_bits, off, expand - overhead(zone_bits))
- == -1)
- goto fail;
-
- /* Try allocating from this zone now. */
- tdb->zone_off = old_size;
- tdb->zhdr = zhdr;
-
-success: