diff options
-rw-r--r-- | Changes | 6 | ||||
-rw-r--r-- | LICENSE | 2 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | lzf.c | 8 | ||||
-rw-r--r-- | lzf.h | 3 | ||||
-rw-r--r-- | lzfP.h | 4 | ||||
-rw-r--r-- | lzf_c.c | 16 | ||||
-rw-r--r-- | lzf_d.c | 21 |
9 files changed, 43 insertions, 21 deletions
@@ -1,5 +1,9 @@ -1.1 +1.1 Tue Dec 23 05:48:32 CET 2003 - removed #warn directive, it's not worth the hassle. + - add LZF_STACK_ARG and AVOID_ERRNO configurations + for embedded systems. + - make it compile cleanly as c++. + - some small documentation and code fixes. 1.0 Sun Nov 17 12:37:37 CET 2002 - slightly better compression ratio, almost unmeasurably @@ -1,4 +1,4 @@ -Copyright (c) 2000-2002 Marc Alexander Lehmann <pcg@goof.com> +Copyright (c) 2000-2003 Marc Alexander Lehmann <pcg@goof.com> Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: diff --git a/Makefile.in b/Makefile.in index 2b9e0a2..ef5b2d3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -VERSION = 1.0 +VERSION = 1.1 prefix = @prefix@ exec_prefix = @exec_prefix@ diff --git a/configure.in b/configure.in index 33b5921..b18a9fb 100644 --- a/configure.in +++ b/configure.in @@ -14,7 +14,7 @@ AC_CHECK_SIZEOF(long, 4) AC_C_CONST if test "$GCC" = yes; then - CFLAGS="$CFLAGS -O2 -funroll-all-loops" + CFLAGS="$CFLAGS -O3 -funroll-all-loops" else AC_MSG_RESULT(no gcc) fi @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002 Marc Alexander Lehmann <pcg@goof.com> + * Copyright (c) 2000-2003 Marc Alexander Lehmann <pcg@goof.com> * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: @@ -37,13 +37,15 @@ #include "lzf.h" +typedef unsigned char u8; + static void usage (int ec) { fprintf (stderr, "\n" - "lzf, a very leightweight compression/decompression filter\n" + "lzf, a very lightweight compression/decompression filter\n" "written by Marc Lehmann <pcg@goof.com> You can find more info at\n" - "http://liblzv.plan9.de/\n" + "http://liblzf.plan9.de/\n" "\n" "USAGE: lzf -c [-b blocksize] | -d\n" " -c compress\n" @@ -56,6 +56,9 @@ * * The buffers must not be overlapping. * + * If the option LZF_STATE_ART is enabled, an extra argument must be + * supplied which is not reflected in this header file. Refer to lzf_c.c. + * */ unsigned int lzf_compress (const void *const in_data, unsigned int in_len, @@ -82,7 +82,8 @@ /* * avoid assigning values to errno variable? for some embedding purposes - * (linux kernel for example), this is not + * (linux kernel for example), this is neccessary. NOTE: this breaks + * the documentation in lzf.h. */ #ifndef AVOID_ERRNO # define AVOID_ERRNO 0 @@ -91,6 +92,7 @@ /* * Wether to pass the LZF_STATE variable as argument, or allocate it * on the stack. For small-stack environments, define this to zero. + * NOTE: this breaks the prototype in lzf.h. */ #ifndef LZF_STATE_ARG # define LZF_STATE_ARG 1 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002 Marc Alexander Lehmann <pcg@goof.com> + * Copyright (c) 2000-2003 Marc Alexander Lehmann <pcg@goof.com> * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: @@ -68,12 +68,18 @@ unsigned int lzf_compress (const void *const in_data, unsigned int in_len, - void *out_data, unsigned int out_len) + void *out_data, unsigned int out_len +#if !LZF_STATE_ARG + , LZF_STATE *htab +#endif + ) { - const u8 *htab[HSIZE]; +#if LZF_STATE_ARG + LZF_STATE htab; +#endif const u8 **hslot; - const u8 *ip = in_data; - u8 *op = out_data; + const u8 *ip = (const u8 *)in_data; + u8 *op = (u8 *)out_data; const u8 *in_end = ip + in_len; u8 *out_end = op + out_len; const u8 *ref; @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002 Marc Alexander Lehmann <pcg@goof.com> + * Copyright (c) 2000-2003 Marc Alexander Lehmann <pcg@goof.com> * * 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 <errno.h> - #include "lzfP.h" +#if AVOID_ERRNO +# define SET_ERRNO(n) +#else +# include <errno.h> +# 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 @@ lzf_decompress (const void *const in_data, unsigned int in_len, if (op + ctrl > out_end) { - errno = E2BIG; + SET_ERRNO (E2BIG); return 0; } @@ -76,13 +81,13 @@ lzf_decompress (const void *const in_data, unsigned int in_len, 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; } |