diff options
author | Kévin THIERRY <kevin.thierry@open.eurogiciel.org> | 2014-12-23 14:06:25 +0100 |
---|---|---|
committer | Kévin THIERRY <kevin.thierry@open.eurogiciel.org> | 2014-12-23 14:06:25 +0100 |
commit | 79a9578a33ecd3093970bd18df677edc9214fafb (patch) | |
tree | 8ae5c6780a1fcd2124e71f27ad9b4256acd24268 /examples/simple.c | |
parent | 1bb1ce141783168d44a38cd1bb6b822eb13114fc (diff) | |
download | lzo-79a9578a33ecd3093970bd18df677edc9214fafb.tar.gz lzo-79a9578a33ecd3093970bd18df677edc9214fafb.tar.bz2 lzo-79a9578a33ecd3093970bd18df677edc9214fafb.zip |
Imported Upstream version 2.08upstream/2.08sandbox/kevinthierry/upstream
Diffstat (limited to 'examples/simple.c')
-rw-r--r-- | examples/simple.c | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/examples/simple.c b/examples/simple.c index 15611c9..42f814a 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -2,19 +2,7 @@ This file is part of the LZO real-time data compression library. - 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 + Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or @@ -53,12 +41,14 @@ #include "lzo/lzo1x.h" /* portability layer */ +static const char *progname = NULL; #define WANT_LZO_MALLOC 1 +#define WANT_XMALLOC 1 #include "examples/portab.h" -/* We want to compress the data block at `in' with length `IN_LEN' to - * the block at `out'. Because the input block may be incompressible, +/* We want to compress the data block at 'in' with length 'IN_LEN' to + * the block at 'out'. Because the input block may be incompressible, * we must provide a little more output space in case that compression * is not possible. */ @@ -78,7 +68,7 @@ int __lzo_cdecl_main main(int argc, char *argv[]) int r; lzo_bytep in; lzo_bytep out; - lzo_bytep wrkmem; + lzo_voidp wrkmem; lzo_uint in_len; lzo_uint out_len; lzo_uint new_len; @@ -88,7 +78,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-2014 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n"); /* * Step 1: initialize the LZO library @@ -96,16 +86,16 @@ 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"); return 4; } /* * Step 2: allocate blocks and the work-memory */ - in = (lzo_bytep) lzo_malloc(IN_LEN); - out = (lzo_bytep) lzo_malloc(OUT_LEN); - wrkmem = (lzo_bytep) lzo_malloc(LZO1X_1_MEM_COMPRESS); + in = (lzo_bytep) xmalloc(IN_LEN); + out = (lzo_bytep) xmalloc(OUT_LEN); + wrkmem = (lzo_voidp) xmalloc(LZO1X_1_MEM_COMPRESS); if (in == NULL || out == NULL || wrkmem == NULL) { printf("out of memory\n"); @@ -121,12 +111,12 @@ int __lzo_cdecl_main main(int argc, char *argv[]) lzo_memset(in,0,in_len); /* - * Step 4: compress from `in' to `out' with LZO1X-1 + * Step 4: compress from 'in' to 'out' with LZO1X-1 */ - r = lzo1x_1_compress(in,in_len,out,&out_len,wrkmem); + 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); + (unsigned long) in_len, (unsigned long) out_len); else { /* this should NEVER happen */ @@ -141,13 +131,13 @@ int __lzo_cdecl_main main(int argc, char *argv[]) } /* - * Step 5: decompress again, now going from `out' to `in' + * Step 5: decompress again, now going from 'out' to 'in' */ new_len = in_len; - r = lzo1x_decompress(out,out_len,in,&new_len,NULL); + 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); + (unsigned long) out_len, (unsigned long) in_len); else { /* this should NEVER happen */ @@ -162,7 +152,5 @@ int __lzo_cdecl_main main(int argc, char *argv[]) return 0; } -/* -vi:ts=4:et -*/ +/* vim:set ts=4 sw=4 et: */ |