diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2022-12-04 00:39:47 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-01-19 16:24:56 +0100 |
commit | 4160b50a0b4c51f8b7191928cdf38d9fb0147fe2 (patch) | |
tree | 996998b7fe506101c8d91aeb71891eaac358902e /include/sqfs | |
parent | 42194bf57d470e548e03c44f5c2340d7d23a3ecb (diff) |
Add a helper function to initialize libsquashfs objects
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/sqfs')
-rw-r--r-- | include/sqfs/predef.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h index f4b544b..39da692 100644 --- a/include/sqfs/predef.h +++ b/include/sqfs/predef.h @@ -162,6 +162,22 @@ static SQFS_INLINE void *sqfs_copy(const void *obj) return NULL; } +/** + * @brief Initialize an object with default callbacks. + * + * @memberof sqfs_object_t + * + * @param obj A pointer to an uninitialized object + */ +static SQFS_INLINE +void sqfs_object_init(void *obj, + void (*destroy_fn)(sqfs_object_t *), + sqfs_object_t *(*copy_fn)(const sqfs_object_t *)) +{ + ((sqfs_object_t *)obj)->destroy = destroy_fn; + ((sqfs_object_t *)obj)->copy = copy_fn; +} + #ifdef __cplusplus extern "C" { #endif |