From be09e56b36dc0449afdfd39bb9d2aa32d0f4f9c7 Mon Sep 17 00:00:00 2001 From: Roy Oursler Date: Mon, 20 Mar 2017 14:38:32 -0700 Subject: [PATCH] igzip: Modify igzip_example to provide example of higher compression levels Change-Id: Iccd0528ac088e1eec3921aa5fde99769d75e3334 Signed-off-by: Roy Oursler --- igzip/igzip_example.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/igzip/igzip_example.c b/igzip/igzip_example.c index 7bf2661..5930c71 100644 --- a/igzip/igzip_example.c +++ b/igzip/igzip_example.c @@ -32,6 +32,11 @@ #include "igzip_lib.h" #define BUF_SIZE 8192 +#ifndef LEVEL +# define LEVEL 0 +#else +# define LEVEL 1 +#endif struct isal_zstream stream; @@ -62,6 +67,16 @@ int main(int argc, char *argv[]) stream.end_of_stream = 0; stream.flush = NO_FLUSH; + if (LEVEL == 1) { + stream.level = 1; + stream.level_buf = malloc(ISAL_DEF_LVL1_DEFAULT); + stream.level_buf_size = ISAL_DEF_LVL1_DEFAULT; + if (stream.level_buf == 0) { + printf("Failed to allocate level compression buffer\n"); + exit(0); + } + } + do { stream.avail_in = (uint32_t) fread(inbuf, 1, BUF_SIZE, in); stream.end_of_stream = feof(in) ? 1 : 0;