summaryrefslogtreecommitdiff
path: root/lib/sqfs/xattr_writer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfs/xattr_writer.c')
-rw-r--r--lib/sqfs/xattr_writer.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/lib/sqfs/xattr_writer.c b/lib/sqfs/xattr_writer.c
index 047e411..827d0c5 100644
--- a/lib/sqfs/xattr_writer.c
+++ b/lib/sqfs/xattr_writer.c
@@ -99,6 +99,8 @@ typedef struct kv_block_desc_t {
} kv_block_desc_t;
struct sqfs_xattr_writer_t {
+ sqfs_object_t base;
+
str_table_t keys;
str_table_t values;
@@ -113,6 +115,23 @@ struct sqfs_xattr_writer_t {
};
+static void xattr_writer_destroy(sqfs_object_t *obj)
+{
+ sqfs_xattr_writer_t *xwr = (sqfs_xattr_writer_t *)obj;
+ kv_block_desc_t *blk;
+
+ while (xwr->kv_blocks != NULL) {
+ blk = xwr->kv_blocks;
+ xwr->kv_blocks = xwr->kv_blocks->next;
+ free(blk);
+ }
+
+ free(xwr->kv_pairs);
+ str_table_cleanup(&xwr->values);
+ str_table_cleanup(&xwr->keys);
+ free(xwr);
+}
+
sqfs_xattr_writer_t *sqfs_xattr_writer_create(void)
{
sqfs_xattr_writer_t *xwr = calloc(1, sizeof(*xwr));
@@ -129,6 +148,7 @@ sqfs_xattr_writer_t *sqfs_xattr_writer_create(void)
if (xwr->kv_pairs == NULL)
goto fail_pairs;
+ ((sqfs_object_t *)xwr)->destroy = xattr_writer_destroy;
return xwr;
fail_pairs:
str_table_cleanup(&xwr->values);
@@ -139,22 +159,6 @@ fail_keys:
return NULL;
}
-void sqfs_xattr_writer_destroy(sqfs_xattr_writer_t *xwr)
-{
- kv_block_desc_t *blk;
-
- while (xwr->kv_blocks != NULL) {
- blk = xwr->kv_blocks;
- xwr->kv_blocks = xwr->kv_blocks->next;
- free(blk);
- }
-
- free(xwr->kv_pairs);
- str_table_cleanup(&xwr->values);
- str_table_cleanup(&xwr->keys);
- free(xwr);
-}
-
int sqfs_xattr_writer_begin(sqfs_xattr_writer_t *xwr)
{
xwr->kv_start = xwr->num_pairs;
@@ -603,6 +607,6 @@ int sqfs_xattr_writer_flush(sqfs_xattr_writer_t *xwr, sqfs_file_t *file,
locations, count);
out:
free(locations);
- sqfs_meta_writer_destroy(mw);
+ sqfs_destroy(mw);
return err;
}