static tdb_len_t free_record_length(struct tdb_context *tdb, tdb_off_t off)
{
struct tdb_free_record f;
+ enum TDB_ERROR ecode;
- if (tdb_read_convert(tdb, off, &f, sizeof(f)) != 0)
- return TDB_OFF_ERR;
+ ecode = tdb_read_convert(tdb, off, &f, sizeof(f));
+ if (ecode != TDB_SUCCESS)
+ return ecode;
if (frec_magic(&f) != TDB_FREE_MAGIC)
- return TDB_OFF_ERR;
+ return TDB_ERR_CORRUPT;
return frec_len(&f);
}
ok1(free_record_length(tdb, layout->elem[1].base.off) == len);
ok1(tdb_check(tdb, NULL, NULL) == 0);
tdb_close(tdb);
+ tdb_layout_free(layout);
/* No coalescing can be done due to used record */
layout = new_tdb_layout(NULL);
ok1(free_record_length(tdb, layout->elem[1].base.off) == 1024);
ok1(tdb_check(tdb, NULL, NULL) == 0);
tdb_close(tdb);
+ tdb_layout_free(layout);
/* Coalescing can be done due to two free records, then EOF */
layout = new_tdb_layout(NULL);
== 1024 + sizeof(struct tdb_used_record) + 2048);
ok1(tdb_check(tdb, NULL, NULL) == 0);
tdb_close(tdb);
+ tdb_layout_free(layout);
/* Coalescing can be done due to two free records, then data */
layout = new_tdb_layout(NULL);
== 1024 + sizeof(struct tdb_used_record) + 512);
ok1(tdb_check(tdb, NULL, NULL) == 0);
tdb_close(tdb);
+ tdb_layout_free(layout);
/* Coalescing can be done due to three free records, then EOF */
layout = new_tdb_layout(NULL);
+ sizeof(struct tdb_used_record) + 256);
ok1(tdb_check(tdb, NULL, NULL) == 0);
tdb_close(tdb);
+ tdb_layout_free(layout);
ok1(tap_log_messages == 0);
return exit_status();