--- Compress-LZF/lzf_d.c 2001/09/27 18:36:34 1.1 +++ Compress-LZF/lzf_d.c 2004/08/03 15:42:02 1.2 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 Marc Alexander Lehmann + * Copyright (c) 2000-2003 Marc Alexander Lehmann * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: @@ -24,18 +24,33 @@ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Alternatively, the contents of this file may be used under the terms of + * the GNU General Public License version 2 (the "GPL"), in which case the + * provisions of the GPL are applicable instead of the above. If you wish to + * allow the use of your version of this file only under the terms of the + * GPL and not to allow others to use your version of this file under the + * BSD license, indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by the GPL. If + * you do not delete the provisions above, a recipient may use your version + * of this file under either the BSD or the GPL. */ -#include - #include "lzfP.h" +#if AVOID_ERRNO +# define SET_ERRNO(n) +#else +# include +# define SET_ERRNO(n) errno = (n) +#endif + unsigned int lzf_decompress (const void *const in_data, unsigned int in_len, void *out_data, unsigned int out_len) { - u8 const *ip = in_data; - u8 *op = out_data; + u8 const *ip = (const u8 *)in_data; + u8 *op = (u8 *)out_data; u8 const *const in_end = ip + in_len; u8 *const out_end = op + out_len; @@ -49,7 +64,7 @@ if (op + ctrl > out_end) { - errno = E2BIG; + SET_ERRNO (E2BIG); return 0; } @@ -76,13 +91,13 @@ if (op + len + 2 > out_end) { - errno = E2BIG; + SET_ERRNO (E2BIG); return 0; } if (ref < (u8 *)out_data) { - errno = EINVAL; + SET_ERRNO (EINVAL); return 0; }