From 43ba19025dd170cfa660ecb92195f8c1ba40080d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 15 Mar 2018 09:19:26 -0600 Subject: [PATCH] Update some function headers. --- include/lzf.h | 70 +++++++++++++++++++++++++++++------------------- libc/lzf/lzf_c.c | 33 +++++++++++++++++++---- libc/lzf/lzf_d.c | 20 ++++++++++++++ 3 files changed, 91 insertions(+), 32 deletions(-) diff --git a/include/lzf.h b/include/lzf.h index 97745b7de14..e9f1813afde 100644 --- a/include/lzf.h +++ b/include/lzf.h @@ -56,44 +56,60 @@ typedef lzf_hslot_t lzf_state_t[1 << HLOG]; * Public Function Prototypes ****************************************************************************/ -/* Compress in_len bytes stored at the memory block starting at - * in_data and write the result to out_data, up to a maximum length - * of out_len bytes. +/**************************************************************************** + * Name: lzf_compress * - * If the output buffer is not large enough or any error occurs return 0, - * otherwise return the number of bytes used, which might be considerably - * more than in_len (but less than 104% of the original size), so it - * makes sense to always use out_len == in_len - 1), to ensure _some_ - * compression, and store the data uncompressed otherwise (with a flag, of - * course. + * Description: + * Compress in_len bytes stored at the memory block starting at + * in_data and write the result to out_data, up to a maximum length + * of out_len bytes. * - * lzf_compress might use different algorithms on different systems and - * even different runs, thus might result in different compressed strings - * depending on the phase of the moon or similar factors. However, all - * these strings are architecture-independent and will result in the - * original data when decompressed using lzf_decompress. + * If the output buffer is not large enough or any error occurs return 0, + * otherwise return the number of bytes used, which might be considerably + * more than in_len (but less than 104% of the original size), so it + * makes sense to always use out_len == in_len - 1), to ensure _some_ + * compression, and store the data uncompressed otherwise (with a flag, of + * course. * - * The buffers must not be overlapping. - */ + * lzf_compress might use different algorithms on different systems and + * even different runs, thus might result in different compressed strings + * depending on the phase of the moon or similar factors. However, all + * these strings are architecture-independent and will result in the + * original data when decompressed using lzf_decompress. + * + * The buffers must not be overlapping. + * + * Compressed format: + * + * 000LLLLL ; literal, L+1=1..33 octets + * LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset + * 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset + * + ****************************************************************************/ unsigned int lzf_compress(FAR const void *const in_data, unsigned int in_len, FAR void *out_data, unsigned int out_len, lzf_state_t htab); -/* Decompress data compressed with some version of the lzf_compress - * function and stored at location in_data and length in_len. The result - * will be stored at out_data up to a maximum of out_len characters. +/**************************************************************************** + * Name: lzf_decompress * - * If the output buffer is not large enough to hold the decompressed - * data, a 0 is returned and errno is set to E2BIG. Otherwise the number - * of decompressed bytes (i.e. the original length of the data) is - * returned. + * Description: + * Decompress data compressed with some version of the lzf_compress + * function and stored at location in_data and length in_len. The result + * will be stored at out_data up to a maximum of out_len characters. * - * If an error in the compressed data is detected, a zero is returned and - * errno is set to EINVAL. + * If the output buffer is not large enough to hold the decompressed + * data, a 0 is returned and errno is set to E2BIG. Otherwise the number + * of decompressed bytes (i.e. the original length of the data) is + * returned. * - * This function is very fast, about as fast as a copying loop. - */ + * If an error in the compressed data is detected, a zero is returned and + * errno is set to EINVAL. + * + * This function is very fast, about as fast as a copying loop. + * + ****************************************************************************/ unsigned int lzf_decompress(FAR const void *const in_data, unsigned int in_len, FAR void *out_data, diff --git a/libc/lzf/lzf_c.c b/libc/lzf/lzf_c.c index b5386e83b11..b7593e150f5 100644 --- a/libc/lzf/lzf_c.c +++ b/libc/lzf/lzf_c.c @@ -92,13 +92,36 @@ * Public Functions ****************************************************************************/ -/* Compressed format +/**************************************************************************** + * Name: lzf_compress * - * 000LLLLL ; literal, L+1=1..33 octets - * LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset - * 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset + * Description: + * Compress in_len bytes stored at the memory block starting at + * in_data and write the result to out_data, up to a maximum length + * of out_len bytes. * - */ + * If the output buffer is not large enough or any error occurs return 0, + * otherwise return the number of bytes used, which might be considerably + * more than in_len (but less than 104% of the original size), so it + * makes sense to always use out_len == in_len - 1), to ensure _some_ + * compression, and store the data uncompressed otherwise (with a flag, of + * course. + * + * lzf_compress might use different algorithms on different systems and + * even different runs, thus might result in different compressed strings + * depending on the phase of the moon or similar factors. However, all + * these strings are architecture-independent and will result in the + * original data when decompressed using lzf_decompress. + * + * The buffers must not be overlapping. + * + * Compressed format: + * + * 000LLLLL ; literal, L+1=1..33 octets + * LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset + * 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset + * + ****************************************************************************/ unsigned int lzf_compress(FAR const void *const in_data, unsigned int in_len, FAR void *out_data, diff --git a/libc/lzf/lzf_d.c b/libc/lzf/lzf_d.c index afbc550dc7a..8e682461077 100644 --- a/libc/lzf/lzf_d.c +++ b/libc/lzf/lzf_d.c @@ -38,6 +38,26 @@ * Public Functions ****************************************************************************/ +/**************************************************************************** + * Name: lzf_decompress + * + * Description: + * Decompress data compressed with some version of the lzf_compress + * function and stored at location in_data and length in_len. The result + * will be stored at out_data up to a maximum of out_len characters. + * + * If the output buffer is not large enough to hold the decompressed + * data, a 0 is returned and errno is set to E2BIG. Otherwise the number + * of decompressed bytes (i.e. the original length of the data) is + * returned. + * + * If an error in the compressed data is detected, a zero is returned and + * errno is set to EINVAL. + * + * This function is very fast, about as fast as a copying loop. + * + ****************************************************************************/ + unsigned int lzf_decompress (FAR const void *const in_data, unsigned int in_len, FAR void *out_data, unsigned int out_len)