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 /extras | |
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 'extras')
-rw-r--r-- | extras/browse.c | 10 | ||||
-rw-r--r-- | extras/extract_one.c | 12 | ||||
-rw-r--r-- | extras/list_files.c | 8 | ||||
-rw-r--r-- | extras/mk42sqfs.c | 12 | ||||
-rw-r--r-- | extras/mknastyfs.c | 12 |
5 files changed, 27 insertions, 27 deletions
diff --git a/extras/browse.c b/extras/browse.c index cc31105..8bc6fc3 100644 --- a/extras/browse.c +++ b/extras/browse.c @@ -612,16 +612,16 @@ int main(int argc, char **argv) status = EXIT_SUCCESS; free(buffer); out: - sqfs_destroy(data); + sqfs_drop(data); out_dir: if (working_dir != NULL) free(working_dir); - sqfs_destroy(dr); + sqfs_drop(dr); out_id: - sqfs_destroy(idtbl); + sqfs_drop(idtbl); out_cmp: - sqfs_destroy(cmp); + sqfs_drop(cmp); out_fd: - sqfs_destroy(file); + sqfs_drop(file); return status; } diff --git a/extras/extract_one.c b/extras/extract_one.c index fcd8124..63c83f9 100644 --- a/extras/extract_one.c +++ b/extras/extract_one.c @@ -165,12 +165,12 @@ int main(int argc, char **argv) status = EXIT_SUCCESS; out: sqfs_dir_tree_destroy(n); - sqfs_destroy(data); - sqfs_destroy(dirrd); - sqfs_destroy(idtbl); - sqfs_destroy(xattr); - sqfs_destroy(cmp); - sqfs_destroy(file); + sqfs_drop(data); + sqfs_drop(dirrd); + sqfs_drop(idtbl); + sqfs_drop(xattr); + sqfs_drop(cmp); + sqfs_drop(file); free(output); return status; diff --git a/extras/list_files.c b/extras/list_files.c index e368f2a..d1e0a64 100644 --- a/extras/list_files.c +++ b/extras/list_files.c @@ -129,12 +129,12 @@ int main(int argc, char **argv) out: if (root != NULL) sqfs_dir_tree_destroy(root); - sqfs_destroy(dr); + sqfs_drop(dr); out_id: - sqfs_destroy(idtbl); + sqfs_drop(idtbl); out_cmp: - sqfs_destroy(cmp); + sqfs_drop(cmp); out_fd: - sqfs_destroy(file); + sqfs_drop(file); return status; } diff --git a/extras/mk42sqfs.c b/extras/mk42sqfs.c index e9b0823..87e1523 100644 --- a/extras/mk42sqfs.c +++ b/extras/mk42sqfs.c @@ -197,16 +197,16 @@ int main(int argc, char **argv) /* cleanup */ status = EXIT_SUCCESS; - sqfs_destroy(idtbl); + sqfs_drop(idtbl); out_dirwr: - sqfs_destroy(dirwr); + sqfs_drop(dirwr); out_dm: - sqfs_destroy(dir_m); + sqfs_drop(dir_m); out_im: - sqfs_destroy(inode_m); + sqfs_drop(inode_m); out_cmp: - sqfs_destroy(cmp); + sqfs_drop(cmp); out_file: - sqfs_destroy(file); + sqfs_drop(file); return status; } diff --git a/extras/mknastyfs.c b/extras/mknastyfs.c index c65759c..c72bd7d 100644 --- a/extras/mknastyfs.c +++ b/extras/mknastyfs.c @@ -176,16 +176,16 @@ int main(int argc, char **argv) /* cleanup */ status = EXIT_SUCCESS; - sqfs_destroy(idtbl); + sqfs_drop(idtbl); out_dirwr: - sqfs_destroy(dirwr); + sqfs_drop(dirwr); out_dm: - sqfs_destroy(dir_m); + sqfs_drop(dir_m); out_im: - sqfs_destroy(inode_m); + sqfs_drop(inode_m); out_cmp: - sqfs_destroy(cmp); + sqfs_drop(cmp); out_file: - sqfs_destroy(file); + sqfs_drop(file); return status; } |