liblzma: Improve documentation in index_hash.h.

All functions now explicitly specify parameter and return values.
Also reworded the description of lzma_index_hash_init() for readability.
This commit is contained in:
Jia Tan 2023-02-10 21:35:23 +08:00
parent 1dbe12b90c
commit 9255fffdb1
1 changed files with 27 additions and 9 deletions

View File

@ -29,13 +29,21 @@ typedef struct lzma_index_hash_s lzma_index_hash;
/** /**
* \brief Allocate and initialize a new lzma_index_hash structure * \brief Allocate and initialize a new lzma_index_hash structure
* *
* If index_hash is NULL, a new lzma_index_hash structure is allocated, * If index_hash is NULL, this function allocates and initializes a new
* initialized, and a pointer to it returned. If allocation fails, NULL * lzma_index_hash structure and returns a pointer to it. If allocation
* is returned. * fails, NULL is returned.
* *
* If index_hash is non-NULL, it is reinitialized and the same pointer * If index_hash is non-NULL, this function reinitializes the lzma_index_hash
* returned. In this case, return value cannot be NULL or a different * structure and returns the same pointer. In this case, return value cannot
* pointer than the index_hash that was given as an argument. * be NULL or a different pointer than the index_hash that was given as
* an argument.
*
* \param index_hash Pointer to a lzma_index_hash structure or NULL.
* \param allocator lzma_allocator for custom allocator functions.
* Set to NULL to use malloc() and free().
*
* \return Initialized lzma_index_hash structure on success or
* NULL on failure.
*/ */
extern LZMA_API(lzma_index_hash *) lzma_index_hash_init( extern LZMA_API(lzma_index_hash *) lzma_index_hash_init(
lzma_index_hash *index_hash, const lzma_allocator *allocator) lzma_index_hash *index_hash, const lzma_allocator *allocator)
@ -44,6 +52,10 @@ extern LZMA_API(lzma_index_hash *) lzma_index_hash_init(
/** /**
* \brief Deallocate lzma_index_hash structure * \brief Deallocate lzma_index_hash structure
*
* \param index_hash Pointer to a lzma_index_hash structure to free.
* \param allocator lzma_allocator for custom allocator functions.
* Set to NULL to use malloc() and free().
*/ */
extern LZMA_API(void) lzma_index_hash_end( extern LZMA_API(void) lzma_index_hash_end(
lzma_index_hash *index_hash, const lzma_allocator *allocator) lzma_index_hash *index_hash, const lzma_allocator *allocator)
@ -57,7 +69,8 @@ extern LZMA_API(void) lzma_index_hash_end(
* \param unpadded_size Unpadded Size of a Block * \param unpadded_size Unpadded Size of a Block
* \param uncompressed_size Uncompressed Size of a Block * \param uncompressed_size Uncompressed Size of a Block
* *
* \return - LZMA_OK * \return Possible lzma_ret values:
* - LZMA_OK
* - LZMA_DATA_ERROR: Compressed or uncompressed size of the * - LZMA_DATA_ERROR: Compressed or uncompressed size of the
* Stream or size of the Index field would grow too big. * Stream or size of the Index field would grow too big.
* - LZMA_PROG_ERROR: Invalid arguments or this function is being * - LZMA_PROG_ERROR: Invalid arguments or this function is being
@ -82,10 +95,11 @@ extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash,
* *
* \param index_hash Pointer to a lzma_index_hash structure * \param index_hash Pointer to a lzma_index_hash structure
* \param in Pointer to the beginning of the input buffer * \param in Pointer to the beginning of the input buffer
* \param in_pos in[*in_pos] is the next byte to process * \param[out] in_pos in[*in_pos] is the next byte to process
* \param in_size in[in_size] is the first byte not to process * \param in_size in[in_size] is the first byte not to process
* *
* \return - LZMA_OK: So far good, but more input is needed. * \return Possible lzma_ret values:
* - LZMA_OK: So far good, but more input is needed.
* - LZMA_STREAM_END: Index decoded successfully and it matches * - LZMA_STREAM_END: Index decoded successfully and it matches
* the Records given with lzma_index_hash_append(). * the Records given with lzma_index_hash_append().
* - LZMA_DATA_ERROR: Index is corrupt or doesn't match the * - LZMA_DATA_ERROR: Index is corrupt or doesn't match the
@ -102,6 +116,10 @@ extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash,
* \brief Get the size of the Index field as bytes * \brief Get the size of the Index field as bytes
* *
* This is needed to verify the Backward Size field in the Stream Footer. * This is needed to verify the Backward Size field in the Stream Footer.
*
* \param index_hash Pointer to a lzma_index_hash structure
*
* \return Size of the Index field in bytes.
*/ */
extern LZMA_API(lzma_vli) lzma_index_hash_size( extern LZMA_API(lzma_vli) lzma_index_hash_size(
const lzma_index_hash *index_hash) const lzma_index_hash *index_hash)