aboutsummaryrefslogtreecommitdiff
path: root/bin/sqfs2tar
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-12-04 01:33:45 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-01-19 16:24:56 +0100
commit47f24f2a8faf71395a1d054e9823beb000442cce (patch)
treedd01d8b69125b3dda444c9b92437ad0c5a0af9bc /bin/sqfs2tar
parent4160b50a0b4c51f8b7191928cdf38d9fb0147fe2 (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/sqfs2tar')
-rw-r--r--bin/sqfs2tar/sqfs2tar.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/bin/sqfs2tar/sqfs2tar.c b/bin/sqfs2tar/sqfs2tar.c
index 00d1e27..9dfa41e 100644
--- a/bin/sqfs2tar/sqfs2tar.c
+++ b/bin/sqfs2tar/sqfs2tar.c
@@ -124,7 +124,11 @@ int main(int argc, char **argv)
}
if (compressor > 0) {
- out_file = ostream_compressor_create(out_file, compressor);
+ ostream_t *strm = ostream_compressor_create(out_file,
+ compressor);
+ sqfs_drop(out_file);
+ out_file = strm;
+
if (out_file == NULL)
goto out_dirs;
}
@@ -251,20 +255,19 @@ out:
if (root != NULL)
sqfs_dir_tree_destroy(root);
out_xr:
- if (xr != NULL)
- sqfs_destroy(xr);
+ sqfs_drop(xr);
out_dr:
- sqfs_destroy(dr);
+ sqfs_drop(dr);
out_data:
- sqfs_destroy(data);
+ sqfs_drop(data);
out_id:
- sqfs_destroy(idtbl);
+ sqfs_drop(idtbl);
out_cmp:
- sqfs_destroy(cmp);
+ sqfs_drop(cmp);
out_fd:
- sqfs_destroy(file);
+ sqfs_drop(file);
out_ostrm:
- sqfs_destroy(out_file);
+ sqfs_drop(out_file);
out_dirs:
for (i = 0; i < num_subdirs; ++i)
free(subdirs[i]);