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/sqfsdiff | |
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/sqfsdiff')
-rw-r--r-- | bin/sqfsdiff/extract.c | 4 | ||||
-rw-r--r-- | bin/sqfsdiff/sqfsdiff.c | 20 |
2 files changed, 12 insertions, 12 deletions
diff --git a/bin/sqfsdiff/extract.c b/bin/sqfsdiff/extract.c index 0c68918..f2072d4 100644 --- a/bin/sqfsdiff/extract.c +++ b/bin/sqfsdiff/extract.c @@ -29,12 +29,12 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode, } if (sqfs_data_reader_dump(path, data, inode, fp, block_size)) { - sqfs_destroy(fp); + sqfs_drop(fp); return -1; } ostream_flush(fp); - sqfs_destroy(fp); + sqfs_drop(fp); return 0; } diff --git a/bin/sqfsdiff/sqfsdiff.c b/bin/sqfsdiff/sqfsdiff.c index 0673f8d..9d29332 100644 --- a/bin/sqfsdiff/sqfsdiff.c +++ b/bin/sqfsdiff/sqfsdiff.c @@ -97,28 +97,28 @@ static int open_sfqs(sqfs_state_t *state, const char *path) return 0; fail_data: - sqfs_destroy(state->data); + sqfs_drop(state->data); fail_tree: sqfs_dir_tree_destroy(state->root); fail_dr: - sqfs_destroy(state->dr); + sqfs_drop(state->dr); fail_id: - sqfs_destroy(state->idtbl); + sqfs_drop(state->idtbl); fail_cmp: - sqfs_destroy(state->cmp); + sqfs_drop(state->cmp); fail_file: - sqfs_destroy(state->file); + sqfs_drop(state->file); return -1; } static void close_sfqs(sqfs_state_t *state) { - sqfs_destroy(state->data); + sqfs_drop(state->data); sqfs_dir_tree_destroy(state->root); - sqfs_destroy(state->dr); - sqfs_destroy(state->idtbl); - sqfs_destroy(state->cmp); - sqfs_destroy(state->file); + sqfs_drop(state->dr); + sqfs_drop(state->idtbl); + sqfs_drop(state->cmp); + sqfs_drop(state->file); } int main(int argc, char **argv) |