diff --git a/include/sqsh_extract_private.h b/include/sqsh_extract_private.h index d91c7bbb6..fbc3e3b52 100644 --- a/include/sqsh_extract_private.h +++ b/include/sqsh_extract_private.h @@ -148,7 +148,8 @@ struct SqshExtractManager { * @privatesection */ struct SqshRcHashMap hash_map; - struct SqshExtractor extractor; + unsigned int compression_id; + uint32_t block_size; struct SqshMapManager *map_manager; struct SqshLru lru; sqsh_mutex_t lock; diff --git a/lib/extract/extract_manager.c b/lib/extract/extract_manager.c index 21edb7b85..d599e4aa4 100644 --- a/lib/extract/extract_manager.c +++ b/lib/extract/extract_manager.c @@ -117,10 +117,8 @@ sqsh__extract_manager_init( enum SqshSuperblockCompressionId compression_id = sqsh_superblock_compression_id(superblock); - rv = sqsh__extractor_init(&manager->extractor, compression_id, block_size); - if (rv < 0) { - goto out; - } + manager->compression_id = compression_id; + manager->block_size = block_size; out: if (rv < 0) { @@ -134,7 +132,15 @@ sqsh__extract_manager_uncompress( struct SqshExtractManager *manager, const struct SqshMapReader *reader, const struct SqshBuffer **target) { int rv = 0; - const struct SqshExtractor *extractor = &manager->extractor; + struct SqshExtractor extractor = {0}; + const enum SqshSuperblockCompressionId compression_id = + manager->compression_id; + const uint32_t block_size = manager->block_size; + + rv = sqsh__extractor_init(&extractor, compression_id, block_size); + if (rv < 0) { + goto out; + } rv = sqsh_mutex_lock(&manager->lock); if (rv < 0) { @@ -154,7 +160,7 @@ sqsh__extract_manager_uncompress( } const uint8_t *data = sqsh__map_reader_data(reader); - rv = sqsh__extractor_to_buffer(extractor, &buffer, data, size); + rv = sqsh__extractor_to_buffer(&extractor, &buffer, data, size); if (rv < 0) { sqsh__buffer_cleanup(&buffer); goto out; @@ -165,6 +171,7 @@ sqsh__extract_manager_uncompress( rv = sqsh__lru_touch(&manager->lru, address); out: + sqsh__extractor_cleanup(&extractor); sqsh_mutex_unlock(&manager->lock); return rv; } @@ -187,7 +194,6 @@ sqsh__extract_manager_release( int sqsh__extract_manager_cleanup(struct SqshExtractManager *manager) { sqsh__lru_cleanup(&manager->lru); - sqsh__extractor_cleanup(&manager->extractor); sqsh__rc_hash_map_cleanup(&manager->hash_map); sqsh_mutex_destroy(&manager->lock);