diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-03-05 22:38:15 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-03-05 22:41:04 +0100 |
commit | 85e36aab1258d8d9ec7b61ce013f167ef8e03ae0 (patch) | |
tree | b1d59cce7894520b53c6b1fa86666d91587aaf82 /include/sqfs | |
parent | 5acb22a6a7168f8b961777482f39a125158def50 (diff) |
Change the signature of sqfs_compressor_create to return an error code
Make sure the function has a way of telling the caller *why* it failed.
This way, the function can convey whether it had an internal error, an
allocation failure, whether the arguments are totaly nonsensical, or
simply that the compressor *or specific configuration* is not supported.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/sqfs')
-rw-r--r-- | include/sqfs/compressor.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/include/sqfs/compressor.h b/include/sqfs/compressor.h index fd5d7e8..1a36c82 100644 --- a/include/sqfs/compressor.h +++ b/include/sqfs/compressor.h @@ -351,13 +351,19 @@ SQFS_API bool sqfs_compressor_exists(SQFS_COMPRESSOR id); /** * @brief Create an instance of a compressor implementation. * + * If this function returns @ref SQFS_ERROR_UNSUPPORTED, it can mean that + * either the compressor is not supported at all by the version of libsquashfs + * you are using, or that the specific configuration that has been requested + * is not supported (e.g. unknown flags, or the local version can only + * uncompress, but not compress). + * * @param cfg A pointer to a compressor configuration. + * @param out Returns a pointer to the compressor on success. * - * @return A pointer to a compressor object on success, NULL on allocation - * failure or if initializing the compressor failed. + * @return Zero on success, an SQFS_ERROR code on failure. */ -SQFS_API -sqfs_compressor_t *sqfs_compressor_create(const sqfs_compressor_config_t *cfg); +SQFS_API int sqfs_compressor_create(const sqfs_compressor_config_t *cfg, + sqfs_compressor_t **out); /** * @brief Get the name of a compressor backend from its ID. |