--- liblzf/lzf_d.c 2002/11/17 11:39:26 1.2 +++ liblzf/lzf_d.c 2003/12/23 04:52:00 1.3 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002 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: @@ -26,16 +26,21 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#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 +54,7 @@ if (op + ctrl > out_end) { - errno = E2BIG; + SET_ERRNO (E2BIG); return 0; } @@ -76,13 +81,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; }