diff options
author | Arne Schwabe <arne@rfc2549.org> | 2012-07-02 17:28:05 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2012-07-02 17:28:05 +0200 |
commit | ace5e90b3dbc33f0fc34ac2f3dc40d3c990a6a11 (patch) | |
tree | 0b5cda436e04ee29efb5220da5634d04455c65c0 /lzo/examples/precomp.c | |
parent | 78172a10165a969b8c002b6bdcf9dc47fa6cd5f3 (diff) |
Update lzo version
Diffstat (limited to 'lzo/examples/precomp.c')
-rw-r--r-- | lzo/examples/precomp.c | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/lzo/examples/precomp.c b/lzo/examples/precomp.c index 10f4e7fe..a953827b 100644 --- a/lzo/examples/precomp.c +++ b/lzo/examples/precomp.c @@ -2,6 +2,9 @@ This file is part of the LZO real-time data compression library. + Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2009 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 @@ -58,9 +61,11 @@ /* portability layer */ +static const char *progname = NULL; #define WANT_LZO_MALLOC 1 #define WANT_LZO_FREAD 1 #define WANT_LZO_WILDARGV 1 +#define WANT_XMALLOC 1 #include "examples/portab.h" @@ -79,7 +84,7 @@ int __lzo_cdecl_main main(int argc, char *argv[]) lzo_uint out_bufsize; lzo_uint out_len = 0; - lzo_bytep wrkmem; + lzo_voidp wrkmem; lzo_uint wrk_len; lzo_uint best_len; @@ -89,8 +94,7 @@ int __lzo_cdecl_main main(int argc, char *argv[]) lzo_uint32 uncompressed_checksum; lzo_uint32 compressed_checksum; - FILE *f; - const char *progname = NULL; + FILE *fp; const char *in_name = NULL; const char *out_name = NULL; long l; @@ -100,7 +104,7 @@ int __lzo_cdecl_main main(int argc, char *argv[]) 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"); + printf("Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n"); progname = argv[0]; if (argc < 2 || argc > 3) @@ -117,7 +121,7 @@ int __lzo_cdecl_main main(int argc, char *argv[]) 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"); + printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n"); exit(1); } @@ -133,7 +137,7 @@ int __lzo_cdecl_main main(int argc, char *argv[]) if (wrk_len < LZO1Y_999_MEM_COMPRESS) wrk_len = LZO1Y_999_MEM_COMPRESS; #endif - wrkmem = (lzo_bytep) lzo_malloc(wrk_len); + wrkmem = (lzo_voidp) xmalloc(wrk_len); if (wrkmem == NULL) { printf("%s: out of memory\n", progname); @@ -143,19 +147,19 @@ int __lzo_cdecl_main main(int argc, char *argv[]) /* * Step 3: open the input file */ - f = fopen(in_name,"rb"); - if (f == NULL) + fp = fopen(in_name,"rb"); + if (fp == NULL) { printf("%s: cannot open file %s\n", progname, in_name); exit(1); } - fseek(f,0,SEEK_END); - l = ftell(f); - fseek(f,0,SEEK_SET); + fseek(fp, 0, SEEK_END); + l = ftell(fp); + fseek(fp, 0, SEEK_SET); if (l <= 0) { printf("%s: %s: empty file\n", progname, in_name); - fclose(f); + fclose(fp); fp = NULL; exit(1); } in_len = (lzo_uint) l; @@ -165,16 +169,16 @@ int __lzo_cdecl_main main(int argc, char *argv[]) /* * Step 4: allocate compression buffers and read the file */ - in = (lzo_bytep) lzo_malloc(in_len); - out = (lzo_bytep) lzo_malloc(out_bufsize); + in = (lzo_bytep) xmalloc(in_len); + out = (lzo_bytep) xmalloc(out_bufsize); if (in == NULL || out == NULL) { printf("%s: out of memory\n", progname); exit(1); } - in_len = (lzo_uint) lzo_fread(f,in,in_len); + in_len = (lzo_uint) lzo_fread(fp, in, in_len); printf("%s: loaded file %s: %ld bytes\n", progname, in_name, (long) in_len); - fclose(f); + fclose(fp); fp = NULL; /* * Step 5: compute a checksum of the uncompressed data @@ -183,7 +187,7 @@ int __lzo_cdecl_main main(int argc, char *argv[]) uncompressed_checksum = lzo_adler32(uncompressed_checksum,in,in_len); /* - * Step 6a: compress from `in' to `out' with LZO1X-999 + * Step 6a: compress from 'in' to 'out' with LZO1X-999 */ #ifdef USE_LZO1X out_len = out_bufsize; @@ -203,7 +207,7 @@ int __lzo_cdecl_main main(int argc, char *argv[]) #endif /* USE_LZO1X */ /* - * Step 6b: compress from `in' to `out' with LZO1Y-999 + * Step 6b: compress from 'in' to 'out' with LZO1Y-999 */ #ifdef USE_LZO1Y out_len = out_bufsize; @@ -245,7 +249,7 @@ int __lzo_cdecl_main main(int argc, char *argv[]) assert(out_len == best_len); /* - * Step 9: optimize compressed data (compressed data is in `out' buffer) + * Step 9: optimize compressed data (compressed data is in 'out' buffer) */ #if 1 /* Optimization does not require any data in the buffer that will @@ -287,13 +291,13 @@ int __lzo_cdecl_main main(int argc, char *argv[]) if (out_name && out_name[0]) { printf("%s: writing to file %s\n", progname, out_name); - f = fopen(out_name,"wb"); - if (f == NULL) + fp = fopen(out_name,"wb"); + if (fp == NULL) { printf("%s: cannot open output file %s\n", progname, out_name); exit(1); } - if (lzo_fwrite(f,out,out_len) != out_len || fclose(f) != 0) + if (lzo_fwrite(fp, out, out_len) != out_len || fclose(fp) != 0) { printf("%s: write error !!\n", progname); exit(1); |