summaryrefslogtreecommitdiff
path: root/lib/sqfs/meta_reader.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-12 02:22:31 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-12 02:26:24 +0100
commit303680ebcd5adaac2934b63a0edc2d9d1a36d7fb (patch)
treebd2012dc6fa56f7259dbe2e5edd7ab3042f8e0a0 /lib/sqfs/meta_reader.c
parentec7a522a520017327dd73b4d8e3787016ee1a31e (diff)
Implement a more explicit object system
Make every dynamically allocated, opaque data structure inherit from a common sqfs_object_t structure with common entry points (e.g. destroy). This removes tons of public API functions and replaces them with a simple sqfs_destroy instead. If semantics of the (until now implicit) object system need to be extended, it can be much more conveniantely done this way. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/meta_reader.c')
-rw-r--r--lib/sqfs/meta_reader.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/sqfs/meta_reader.c b/lib/sqfs/meta_reader.c
index 19e856a..8fd7f21 100644
--- a/lib/sqfs/meta_reader.c
+++ b/lib/sqfs/meta_reader.c
@@ -18,6 +18,8 @@
#include <string.h>
struct sqfs_meta_reader_t {
+ sqfs_object_t base;
+
sqfs_u64 start;
sqfs_u64 limit;
size_t data_used;
@@ -44,6 +46,11 @@ struct sqfs_meta_reader_t {
sqfs_u8 scratch[SQFS_META_BLOCK_SIZE];
};
+static void meta_reader_destroy(sqfs_object_t *m)
+{
+ free(m);
+}
+
sqfs_meta_reader_t *sqfs_meta_reader_create(sqfs_file_t *file,
sqfs_compressor_t *cmp,
sqfs_u64 start, sqfs_u64 limit)
@@ -53,6 +60,7 @@ sqfs_meta_reader_t *sqfs_meta_reader_create(sqfs_file_t *file,
if (m == NULL)
return NULL;
+ ((sqfs_object_t *)m)->destroy = meta_reader_destroy;
m->start = start;
m->limit = limit;
m->file = file;
@@ -60,11 +68,6 @@ sqfs_meta_reader_t *sqfs_meta_reader_create(sqfs_file_t *file,
return m;
}
-void sqfs_meta_reader_destroy(sqfs_meta_reader_t *m)
-{
- free(m);
-}
-
int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, sqfs_u64 block_start,
size_t offset)
{