From 47f24f2a8faf71395a1d054e9823beb000442cce Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 4 Dec 2022 01:33:45 +0100 Subject: 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 --- lib/io/compress/ostream_compressor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/io/compress/ostream_compressor.c') diff --git a/lib/io/compress/ostream_compressor.c b/lib/io/compress/ostream_compressor.c index f63a3d2..a5f16d5 100644 --- a/lib/io/compress/ostream_compressor.c +++ b/lib/io/compress/ostream_compressor.c @@ -56,7 +56,7 @@ static void comp_destroy(sqfs_object_t *obj) ostream_comp_t *comp = (ostream_comp_t *)obj; comp->cleanup(comp); - sqfs_destroy(comp->wrapped); + sqfs_drop(comp->wrapped); free(comp); } @@ -95,7 +95,7 @@ ostream_t *ostream_compressor_create(ostream_t *strm, int comp_id) sqfs_object_init(comp, comp_destroy, NULL); - comp->wrapped = strm; + comp->wrapped = sqfs_grab(strm); comp->inbuf_used = 0; base = (ostream_t *)comp; -- cgit v1.2.3