X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=ccan%2Ftdb2%2Ftest%2Frun-03-coalesce.c;h=621ed01bd401679c51e388f88b022def7f3d3ba1;hb=b24f8e2ae5ac22fc2e5dbfebebf9c5fa2f338588;hp=4def490ffdb281c9e8e830512d90f51a38bce4eb;hpb=5e30abc662990449444769c71cf98ca788db4117;p=ccan diff --git a/ccan/tdb2/test/run-03-coalesce.c b/ccan/tdb2/test/run-03-coalesce.c index 4def490f..621ed01b 100644 --- a/ccan/tdb2/test/run-03-coalesce.c +++ b/ccan/tdb2/test/run-03-coalesce.c @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) /* No coalescing can be done due to EOF */ layout = new_tdb_layout(NULL); - tdb_layout_add_freelist(layout); + tdb_layout_add_freetable(layout); len = 1024; tdb_layout_add_free(layout, len, 0); tdb = tdb_layout_get(layout); @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) ok1(free_record_length(tdb, layout->elem[1].base.off) == len); /* Figure out which bucket free entry is. */ - b_off = bucket_off(tdb->flist_off, size_to_bucket(len)); + b_off = bucket_off(tdb->ftable_off, size_to_bucket(len)); /* Lock and fail to coalesce. */ ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0); ok1(coalesce(tdb, layout->elem[1].base.off, b_off, len) == 0); @@ -54,10 +54,11 @@ int main(int argc, char *argv[]) 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); - tdb_layout_add_freelist(layout); + tdb_layout_add_freetable(layout); tdb_layout_add_free(layout, 1024, 0); tdb_layout_add_used(layout, key, data, 6); tdb = tdb_layout_get(layout); @@ -65,7 +66,7 @@ int main(int argc, char *argv[]) ok1(tdb_check(tdb, NULL, NULL) == 0); /* Figure out which bucket free entry is. */ - b_off = bucket_off(tdb->flist_off, size_to_bucket(1024)); + b_off = bucket_off(tdb->ftable_off, size_to_bucket(1024)); /* Lock and fail to coalesce. */ ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0); ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024) == 0); @@ -73,10 +74,11 @@ int main(int argc, char *argv[]) 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); - tdb_layout_add_freelist(layout); + tdb_layout_add_freetable(layout); tdb_layout_add_free(layout, 1024, 0); tdb_layout_add_free(layout, 2048, 0); tdb = tdb_layout_get(layout); @@ -85,7 +87,7 @@ int main(int argc, char *argv[]) ok1(tdb_check(tdb, NULL, NULL) == 0); /* Figure out which bucket (first) free entry is. */ - b_off = bucket_off(tdb->flist_off, size_to_bucket(1024)); + b_off = bucket_off(tdb->ftable_off, size_to_bucket(1024)); /* Lock and coalesce. */ ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0); ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024) == 1); @@ -94,10 +96,11 @@ int main(int argc, char *argv[]) == 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); - tdb_layout_add_freelist(layout); + tdb_layout_add_freetable(layout); tdb_layout_add_free(layout, 1024, 0); tdb_layout_add_free(layout, 512, 0); tdb_layout_add_used(layout, key, data, 6); @@ -107,7 +110,7 @@ int main(int argc, char *argv[]) ok1(tdb_check(tdb, NULL, NULL) == 0); /* Figure out which bucket free entry is. */ - b_off = bucket_off(tdb->flist_off, size_to_bucket(1024)); + b_off = bucket_off(tdb->ftable_off, size_to_bucket(1024)); /* Lock and coalesce. */ ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0); ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024) == 1); @@ -116,10 +119,11 @@ int main(int argc, char *argv[]) == 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); - tdb_layout_add_freelist(layout); + tdb_layout_add_freetable(layout); tdb_layout_add_free(layout, 1024, 0); tdb_layout_add_free(layout, 512, 0); tdb_layout_add_free(layout, 256, 0); @@ -130,7 +134,7 @@ int main(int argc, char *argv[]) ok1(tdb_check(tdb, NULL, NULL) == 0); /* Figure out which bucket free entry is. */ - b_off = bucket_off(tdb->flist_off, size_to_bucket(1024)); + b_off = bucket_off(tdb->ftable_off, size_to_bucket(1024)); /* Lock and coalesce. */ ok1(tdb_lock_free_bucket(tdb, b_off, TDB_LOCK_WAIT) == 0); ok1(coalesce(tdb, layout->elem[1].base.off, b_off, 1024) == 1); @@ -140,6 +144,7 @@ int main(int argc, char *argv[]) + 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();