summaryrefslogtreecommitdiff
path: root/lib/sqfs/data_reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfs/data_reader.c')
-rw-r--r--lib/sqfs/data_reader.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/sqfs/data_reader.c b/lib/sqfs/data_reader.c
index c8886c5..8c9bb2e 100644
--- a/lib/sqfs/data_reader.c
+++ b/lib/sqfs/data_reader.c
@@ -21,6 +21,8 @@
#include <string.h>
struct sqfs_data_reader_t {
+ sqfs_object_t obj;
+
sqfs_frag_table_t *frag_tbl;
sqfs_compressor_t *cmp;
sqfs_file_t *file;
@@ -125,6 +127,16 @@ static int precache_fragment_block(sqfs_data_reader_t *data, size_t idx)
&data->frag_blk_size, &data->frag_block);
}
+static void data_reader_destroy(sqfs_object_t *obj)
+{
+ sqfs_data_reader_t *data = (sqfs_data_reader_t *)obj;
+
+ sqfs_destroy(data->frag_tbl);
+ free(data->data_block);
+ free(data->frag_block);
+ free(data);
+}
+
sqfs_data_reader_t *sqfs_data_reader_create(sqfs_file_t *file,
size_t block_size,
sqfs_compressor_t *cmp)
@@ -140,6 +152,7 @@ sqfs_data_reader_t *sqfs_data_reader_create(sqfs_file_t *file,
return NULL;
}
+ ((sqfs_object_t *)data)->destroy = data_reader_destroy;
data->file = file;
data->block_size = block_size;
data->cmp = cmp;
@@ -164,14 +177,6 @@ int sqfs_data_reader_load_fragment_table(sqfs_data_reader_t *data,
return 0;
}
-void sqfs_data_reader_destroy(sqfs_data_reader_t *data)
-{
- sqfs_frag_table_destroy(data->frag_tbl);
- free(data->data_block);
- free(data->frag_block);
- free(data);
-}
-
int sqfs_data_reader_get_block(sqfs_data_reader_t *data,
const sqfs_inode_generic_t *inode,
size_t index, size_t *size, sqfs_u8 **out)