diff options
Diffstat (limited to 'src/3rdparty/minilzo/testmini.c')
-rw-r--r-- | src/3rdparty/minilzo/testmini.c | 136 |
1 files changed, 72 insertions, 64 deletions
diff --git a/src/3rdparty/minilzo/testmini.c b/src/3rdparty/minilzo/testmini.c index d79aeaf15..022edaf73 100644 --- a/src/3rdparty/minilzo/testmini.c +++ b/src/3rdparty/minilzo/testmini.c @@ -2,7 +2,20 @@ This file is part of the LZO real-time data compression library. - Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. The LZO library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -17,16 +30,16 @@ You should have received a copy of the GNU General Public License along with the LZO library; see the file COPYING. If not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Markus F.X.J. Oberhumer <markus@oberhumer.com> + http://www.oberhumer.com/opensource/lzo/ */ #include <stdio.h> #include <stdlib.h> -#include <string.h> /************************************************************************* @@ -51,14 +64,16 @@ */ #if defined(__LZO_STRICT_16BIT) -#define IN_LEN (8*1024) +#define IN_LEN (8*1024u) +#elif defined(LZO_ARCH_I086) && !defined(LZO_HAVE_MM_HUGE_ARRAY) +#define IN_LEN (60*1024u) #else -#define IN_LEN (128*1024L) +#define IN_LEN (128*1024ul) #endif -#define OUT_LEN (IN_LEN + IN_LEN / 64 + 16 + 3) +#define OUT_LEN (IN_LEN + IN_LEN / 16 + 64 + 3) -static lzo_byte in [ IN_LEN ]; -static lzo_byte out [ OUT_LEN ]; +static unsigned char __LZO_MMODEL in [ IN_LEN ]; +static unsigned char __LZO_MMODEL out [ OUT_LEN ]; /* Work-memory needed for compression. Allocate memory in units @@ -66,7 +81,7 @@ static lzo_byte out [ OUT_LEN ]; */ #define HEAP_ALLOC(var,size) \ - lzo_align_t __LZO_MMODEL var [ ((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t) ] + lzo_align_t __LZO_MMODEL var [ ((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t) ] static HEAP_ALLOC(wrkmem,LZO1X_1_MEM_COMPRESS); @@ -77,84 +92,77 @@ static HEAP_ALLOC(wrkmem,LZO1X_1_MEM_COMPRESS); int main(int argc, char *argv[]) { - int r; - lzo_uint in_len; - lzo_uint out_len; - lzo_uint new_len; - -#if defined(__EMX__) - _response(&argc,&argv); - _wildcard(&argc,&argv); -#endif + int r; + lzo_uint in_len; + lzo_uint out_len; + lzo_uint new_len; - if (argc < 0 && argv == NULL) /* avoid warning about unused args */ - return 0; + if (argc < 0 && argv == NULL) /* avoid warning about unused args */ + return 0; -#if 0 - printf("\nLZO real-time data compression library (v%s, %s).\n", - lzo_version_string(), lzo_version_date()); - printf("Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer\n\n"); -#endif + printf("\nLZO real-time data compression library (v%s, %s).\n", + lzo_version_string(), lzo_version_date()); + printf("Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n"); /* * Step 1: initialize the LZO library */ -#if 0 - if (lzo_init() != LZO_E_OK) - { - printf("lzo_init() failed !!!\n"); - return 3; - } -#endif + if (lzo_init() != LZO_E_OK) + { + printf("internal error - lzo_init() failed !!!\n"); + printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable `-DLZO_DEBUG' for diagnostics)\n"); + return 3; + } /* * Step 2: prepare the input block that will get compressed. * We just fill it with zeros in this example program, * but you would use your real-world data here. */ - in_len = IN_LEN; - memset(in,0,in_len); + in_len = IN_LEN; + lzo_memset(in,0,in_len); /* * Step 3: compress from `in' to `out' with LZO1X-1 */ - r = lzo1x_1_compress(in,in_len,out,&out_len,wrkmem); - if (r == LZO_E_OK) - printf("compressed %lu bytes into %lu bytes\n", - (long) in_len, (long) out_len); - else - { - /* this should NEVER happen */ - printf("internal error - compression failed: %d\n", r); - return 2; - } - /* check for an incompressible block */ - if (out_len >= in_len) - { - printf("This block contains incompressible data.\n"); - return 0; - } + r = lzo1x_1_compress(in,in_len,out,&out_len,wrkmem); + if (r == LZO_E_OK) + printf("compressed %lu bytes into %lu bytes\n", + (unsigned long) in_len, (unsigned long) out_len); + else + { + /* this should NEVER happen */ + printf("internal error - compression failed: %d\n", r); + return 2; + } + /* check for an incompressible block */ + if (out_len >= in_len) + { + printf("This block contains incompressible data.\n"); + return 0; + } /* * Step 4: decompress again, now going from `out' to `in' */ - r = lzo1x_decompress(out,out_len,in,&new_len,NULL); - if (r == LZO_E_OK && new_len == in_len) - printf("decompressed %lu bytes back into %lu bytes\n", - (long) out_len, (long) in_len); - else - { - /* this should NEVER happen */ - printf("internal error - decompression failed: %d\n", r); - return 1; - } - - printf("\nminiLZO simple compression test passed.\n"); - return 0; + new_len = in_len; + r = lzo1x_decompress(out,out_len,in,&new_len,NULL); + if (r == LZO_E_OK && new_len == in_len) + printf("decompressed %lu bytes back into %lu bytes\n", + (unsigned long) out_len, (unsigned long) in_len); + else + { + /* this should NEVER happen */ + printf("internal error - decompression failed: %d\n", r); + return 1; + } + + printf("\nminiLZO simple compression test passed.\n"); + return 0; } /* -vi:ts=4 +vi:ts=4:et */ |