diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2022-12-04 01:33:45 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-01-19 16:24:56 +0100 |
commit | 47f24f2a8faf71395a1d054e9823beb000442cce (patch) | |
tree | dd01d8b69125b3dda444c9b92437ad0c5a0af9bc /tests | |
parent | 4160b50a0b4c51f8b7191928cdf38d9fb0147fe2 (diff) |
Implement rudimentary reference counting for sqfs_object_t
Implement grab/drop functions to increase/decrease reference count
and destroy the object if the count drops to 0.
Make sure that all objects that maintain internal references actually
grab that reference, duplicate it in the copy function, drop it in
the destroy handler.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libio/get_line.c | 2 | ||||
-rw-r--r-- | tests/libio/uncompress.c | 2 | ||||
-rw-r--r-- | tests/libsqfs/table.c | 6 | ||||
-rw-r--r-- | tests/libsqfs/xattr_benchmark.c | 4 | ||||
-rw-r--r-- | tests/libsqfs/xattr_writer.c | 6 | ||||
-rw-r--r-- | tests/libtar/tar_big_file.c | 2 | ||||
-rw-r--r-- | tests/libtar/tar_fuzz.c | 4 | ||||
-rw-r--r-- | tests/libtar/tar_simple.c | 2 | ||||
-rw-r--r-- | tests/libtar/tar_sparse.c | 2 | ||||
-rw-r--r-- | tests/libtar/tar_sparse_gnu.c | 2 | ||||
-rw-r--r-- | tests/libtar/tar_target_filled.c | 3 | ||||
-rw-r--r-- | tests/libtar/tar_xattr.c | 2 | ||||
-rw-r--r-- | tests/libtar/tar_xattr_bin.c | 2 | ||||
-rw-r--r-- | tests/libutil/str_table.c | 2 |
14 files changed, 20 insertions, 21 deletions
diff --git a/tests/libio/get_line.c b/tests/libio/get_line.c index eec53f4..2d0f9b7 100644 --- a/tests/libio/get_line.c +++ b/tests/libio/get_line.c @@ -47,7 +47,7 @@ static void run_test_case(const line_t *lines, size_t count, ret = istream_get_line(fp, &line, &line_num, flags); TEST_ASSERT(ret > 0); - sqfs_destroy(fp); + sqfs_drop(fp); } static const line_t lines_raw[] = { diff --git a/tests/libio/uncompress.c b/tests/libio/uncompress.c index 0b877d8..4ff20b5 100644 --- a/tests/libio/uncompress.c +++ b/tests/libio/uncompress.c @@ -427,6 +427,6 @@ int main(int argc, char **argv) TEST_EQUAL_I(ret, 0); /* cleanup */ - sqfs_destroy(xfrm); + sqfs_drop(xfrm); return EXIT_SUCCESS; } diff --git a/tests/libsqfs/table.c b/tests/libsqfs/table.c index ed373a7..3e44fa3 100644 --- a/tests/libsqfs/table.c +++ b/tests/libsqfs/table.c @@ -84,7 +84,7 @@ static sqfs_s32 dummy_uncompress(sqfs_compressor_t *cmp, const sqfs_u8 *in, } static sqfs_file_t dummy_file = { - { NULL, NULL }, + { 1, NULL, NULL }, dummy_read_at, dummy_write_at, dummy_get_size, @@ -92,7 +92,7 @@ static sqfs_file_t dummy_file = { }; static sqfs_compressor_t dummy_compressor = { - { NULL, NULL }, + { 1, NULL, NULL }, NULL, NULL, NULL, @@ -100,7 +100,7 @@ static sqfs_compressor_t dummy_compressor = { }; static sqfs_compressor_t dummy_uncompressor = { - { NULL, NULL }, + { 1, NULL, NULL }, NULL, NULL, NULL, diff --git a/tests/libsqfs/xattr_benchmark.c b/tests/libsqfs/xattr_benchmark.c index 918a636..072dd06 100644 --- a/tests/libsqfs/xattr_benchmark.c +++ b/tests/libsqfs/xattr_benchmark.c @@ -113,10 +113,10 @@ int main(int argc, char **argv) } /* cleanup */ - sqfs_destroy(xwr); + sqfs_drop(xwr); return EXIT_SUCCESS; fail: - sqfs_destroy(xwr); + sqfs_drop(xwr); return EXIT_FAILURE; fail_arg: fputs("Try `xattr_benchmark --help' for more information.\n", stderr); diff --git a/tests/libsqfs/xattr_writer.c b/tests/libsqfs/xattr_writer.c index dfc8966..f7d0734 100644 --- a/tests/libsqfs/xattr_writer.c +++ b/tests/libsqfs/xattr_writer.c @@ -54,7 +54,7 @@ static sqfs_s32 dummy_compress(sqfs_compressor_t *cmp, const sqfs_u8 *in, } static sqfs_file_t dummy_file = { - { NULL, NULL }, + { 1, NULL, NULL }, NULL, dummy_write_at, dummy_get_size, @@ -62,7 +62,7 @@ static sqfs_file_t dummy_file = { }; static sqfs_compressor_t dummy_compressor = { - { NULL, NULL }, + { 1, NULL, NULL }, NULL, NULL, NULL, @@ -318,6 +318,6 @@ int main(int argc, char **argv) TEST_EQUAL_UI(offset, file_used); /* cleanup */ - sqfs_destroy(xwr); + sqfs_drop(xwr); return EXIT_SUCCESS; } diff --git a/tests/libtar/tar_big_file.c b/tests/libtar/tar_big_file.c index dbeefac..deb41f4 100644 --- a/tests/libtar/tar_big_file.c +++ b/tests/libtar/tar_big_file.c @@ -26,6 +26,6 @@ int main(int argc, char **argv) TEST_STR_EQUAL(hdr.name, "big-file.bin"); TEST_ASSERT(!hdr.unknown_record); clear_header(&hdr); - sqfs_destroy(fp); + sqfs_drop(fp); return EXIT_SUCCESS; } diff --git a/tests/libtar/tar_fuzz.c b/tests/libtar/tar_fuzz.c index 5942426..21e6978 100644 --- a/tests/libtar/tar_fuzz.c +++ b/tests/libtar/tar_fuzz.c @@ -41,9 +41,9 @@ int main(int argc, char **argv) goto fail; } - sqfs_destroy(fp); + sqfs_drop(fp); return EXIT_SUCCESS; fail: - sqfs_destroy(fp); + sqfs_drop(fp); return EXIT_FAILURE; } diff --git a/tests/libtar/tar_simple.c b/tests/libtar/tar_simple.c index 8879f05..cb38abb 100644 --- a/tests/libtar/tar_simple.c +++ b/tests/libtar/tar_simple.c @@ -59,6 +59,6 @@ int main(int argc, char **argv) buffer[5] = '\0'; TEST_STR_EQUAL(buffer, "test\n"); clear_header(&hdr); - sqfs_destroy(fp); + sqfs_drop(fp); return EXIT_SUCCESS; } diff --git a/tests/libtar/tar_sparse.c b/tests/libtar/tar_sparse.c index 511c7ba..27ce053 100644 --- a/tests/libtar/tar_sparse.c +++ b/tests/libtar/tar_sparse.c @@ -75,7 +75,7 @@ static void test_case_sparse(const char *path) TEST_NULL(sparse); clear_header(&hdr); - sqfs_destroy(fp); + sqfs_drop(fp); } int main(int argc, char **argv) diff --git a/tests/libtar/tar_sparse_gnu.c b/tests/libtar/tar_sparse_gnu.c index 37167d3..19ddd0a 100644 --- a/tests/libtar/tar_sparse_gnu.c +++ b/tests/libtar/tar_sparse_gnu.c @@ -47,6 +47,6 @@ int main(int argc, char **argv) TEST_NULL(sparse->next); clear_header(&hdr); - sqfs_destroy(fp); + sqfs_drop(fp); return EXIT_SUCCESS; } diff --git a/tests/libtar/tar_target_filled.c b/tests/libtar/tar_target_filled.c index 6c83170..abc6a47 100644 --- a/tests/libtar/tar_target_filled.c +++ b/tests/libtar/tar_target_filled.c @@ -104,7 +104,6 @@ int main(int argc, char **argv) /* end of file */ TEST_ASSERT(read_header(fp, &hdr) > 0); - sqfs_destroy(fp); - + sqfs_drop(fp); return EXIT_SUCCESS; } diff --git a/tests/libtar/tar_xattr.c b/tests/libtar/tar_xattr.c index 4b3ed21..122d1db 100644 --- a/tests/libtar/tar_xattr.c +++ b/tests/libtar/tar_xattr.c @@ -37,6 +37,6 @@ int main(int argc, char **argv) TEST_NULL(hdr.xattr->next); clear_header(&hdr); - sqfs_destroy(fp); + sqfs_drop(fp); return EXIT_SUCCESS; } diff --git a/tests/libtar/tar_xattr_bin.c b/tests/libtar/tar_xattr_bin.c index b5644a1..90443a1 100644 --- a/tests/libtar/tar_xattr_bin.c +++ b/tests/libtar/tar_xattr_bin.c @@ -45,6 +45,6 @@ int main(int argc, char **argv) TEST_NULL(hdr.xattr->next); clear_header(&hdr); - sqfs_destroy(fp); + sqfs_drop(fp); return EXIT_SUCCESS; } diff --git a/tests/libutil/str_table.c b/tests/libutil/str_table.c index 9424581..d4160eb 100644 --- a/tests/libutil/str_table.c +++ b/tests/libutil/str_table.c @@ -30,7 +30,7 @@ static int read_strings(void) strings[i] = line; } - sqfs_destroy(fp); + sqfs_drop(fp); return 0; } |