- zhdr.zone_bits = zone_bits;
- num_buckets = BUCKETS_FOR_ZONE(zone_bits);
-
- if (tdb->methods->expand_file(tdb, 1ULL << zone_bits) == -1)
- goto fail;
-
- /* Write new tailer. */
- if (tdb->methods->write(tdb, tdb->map_size - 1, &zone_bits, 1) == -1)
- goto fail;
-
- /* Write new zone header (just before old tailer). */
- off = old_size - 1;
- 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, tdb->map_size-1-off) == -1)
- goto fail;
-
- /* Try allocating from this zone now. */
- tdb->zone_off = old_size - 1;
- tdb->zhdr = zhdr;
-
-success:
- tdb_unlock_expand(tdb, F_WRLCK);
- return 0;
+ if (tdb->methods->expand_file(tdb, wanted) == -1) {
+ tdb_unlock_expand(tdb, F_WRLCK);
+ return -1;
+ }