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 /bin/tar2sqfs | |
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 'bin/tar2sqfs')
-rw-r--r-- | bin/tar2sqfs/process_tarball.c | 2 | ||||
-rw-r--r-- | bin/tar2sqfs/tar2sqfs.c | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/bin/tar2sqfs/process_tarball.c b/bin/tar2sqfs/process_tarball.c index c0ae5a3..6aaa24b 100644 --- a/bin/tar2sqfs/process_tarball.c +++ b/bin/tar2sqfs/process_tarball.c @@ -72,7 +72,7 @@ static int write_file(istream_t *input_file, sqfs_writer_t *sqfs, } ostream_flush(out); - sqfs_destroy(out); + sqfs_drop(out); if (ret) return -1; diff --git a/bin/tar2sqfs/tar2sqfs.c b/bin/tar2sqfs/tar2sqfs.c index 4e9ade9..572eb10 100644 --- a/bin/tar2sqfs/tar2sqfs.c +++ b/bin/tar2sqfs/tar2sqfs.c @@ -50,6 +50,8 @@ int main(int argc, char **argv) goto out_if; if (ret > 0) { + istream_t *strm; + if (!io_compressor_exists(ret)) { fprintf(stderr, "%s: %s compression is not supported.\n", @@ -58,7 +60,10 @@ int main(int argc, char **argv) goto out_if; } - input_file = istream_compressor_create(input_file, ret); + strm = istream_compressor_create(input_file, ret); + sqfs_drop(input_file); + input_file = strm; + if (input_file == NULL) return EXIT_FAILURE; } @@ -80,6 +85,6 @@ int main(int argc, char **argv) out: sqfs_writer_cleanup(&sqfs, status); out_if: - sqfs_destroy(input_file); + sqfs_drop(input_file); return status; } |