diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2015-05-03 19:57:21 (GMT) |
---|---|---|
committer | Yann Collet <yann.collet.73@gmail.com> | 2015-05-03 19:57:21 (GMT) |
commit | e05088d0eb500d8d673e081929620e538df3d718 (patch) | |
tree | e2d9a3b37d7ebc61a27877565197d4189b99beac /examples | |
parent | b4348a47189f7bce93537a85906d26b09be7e802 (diff) | |
download | lz4-e05088d0eb500d8d673e081929620e538df3d718.zip lz4-e05088d0eb500d8d673e081929620e538df3d718.tar.gz lz4-e05088d0eb500d8d673e081929620e538df3d718.tar.bz2 |
Updated lz4hc API
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile | 25 | ||||
-rw-r--r-- | examples/blockStreaming_doubleBuffer.c | 8 | ||||
-rw-r--r-- | examples/blockStreaming_lineByLine.c | 12 |
3 files changed, 19 insertions, 26 deletions
diff --git a/examples/Makefile b/examples/Makefile index 0c4cf13..808b511 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,6 +1,7 @@ # ########################################################################## # LZ4 examples - Makefile # Copyright (C) Yann Collet 2011-2014 +# # GPL v2 License # # This program is free software; you can redistribute it and/or modify @@ -21,29 +22,17 @@ # - LZ4 source repository : http://code.google.com/p/lz4/ # - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c # ########################################################################## -# lz4 : Command Line Utility, supporting gzip-like arguments -# lz4c : CLU, supporting also legacy lz4demo arguments -# lz4c32: Same as lz4c, but forced to compile in 32-bits mode -# fuzzer : Test tool, to check lz4 integrity on target platform -# fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode -# fullbench : Precisely measure speed for each LZ4 function variant -# fullbench32: Same as fullbench, but forced to compile in 32-bits mode +# This makefile compile and test +# example programs, using (mostly) LZ4 streaming library, +# kindly provided by Takayuki Matsuoka # ########################################################################## -CC := $(CC) CFLAGS ?= -O3 -CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wno-missing-braces # Wno-missing-braces required due to GCC <4.8.3 bug -FLAGS = -I../lib $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) +CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes +FLAGS := -I../lib $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) TESTFILE= Makefile -LZ4DIR = ../lib - - -# Minimize test target for Travis CI's Build Matrix -ifeq ($(LZ4_TRAVIS_CI_ENV),-m32) -CFLAGS += -m32 -else ifeq ($(LZ4_TRAVIS_CI_ENV),-m64) -endif +LZ4DIR := ../lib # Define *.exe as extension for Windows systems diff --git a/examples/blockStreaming_doubleBuffer.c b/examples/blockStreaming_doubleBuffer.c index 59355da..efe6fc6 100644 --- a/examples/blockStreaming_doubleBuffer.c +++ b/examples/blockStreaming_doubleBuffer.c @@ -38,11 +38,13 @@ size_t read_bin(FILE* fp, void* array, size_t arrayBytes) { void test_compress(FILE* outFp, FILE* inpFp) { - LZ4_stream_t lz4Stream_body = { 0 }; + LZ4_stream_t lz4Stream_body; LZ4_stream_t* lz4Stream = &lz4Stream_body; char inpBuf[2][BLOCK_BYTES]; int inpBufIndex = 0; + + LZ4_resetStream(lz4Stream); for(;;) { char* const inpPtr = inpBuf[inpBufIndex]; @@ -71,12 +73,14 @@ void test_compress(FILE* outFp, FILE* inpFp) void test_decompress(FILE* outFp, FILE* inpFp) { - LZ4_streamDecode_t lz4StreamDecode_body = { 0 }; + LZ4_streamDecode_t lz4StreamDecode_body; LZ4_streamDecode_t* lz4StreamDecode = &lz4StreamDecode_body; char decBuf[2][BLOCK_BYTES]; int decBufIndex = 0; + LZ4_setStreamDecode(lz4StreamDecode, NULL, 0); + for(;;) { char cmpBuf[LZ4_COMPRESSBOUND(BLOCK_BYTES)]; int cmpBytes = 0; diff --git a/examples/blockStreaming_lineByLine.c b/examples/blockStreaming_lineByLine.c index c4fd2e3..f449aa3 100644 --- a/examples/blockStreaming_lineByLine.c +++ b/examples/blockStreaming_lineByLine.c @@ -42,8 +42,8 @@ static void test_compress( { LZ4_stream_t* const lz4Stream = LZ4_createStream(); const size_t cmpBufBytes = LZ4_COMPRESSBOUND(messageMaxBytes); - char* const cmpBuf = malloc(cmpBufBytes); - char* const inpBuf = malloc(ringBufferBytes); + char* const cmpBuf = (char*) malloc(cmpBufBytes); + char* const inpBuf = (char*) malloc(ringBufferBytes); int inpOffset = 0; for ( ; ; ) @@ -90,8 +90,8 @@ static void test_decompress( size_t ringBufferBytes) { LZ4_streamDecode_t* const lz4StreamDecode = LZ4_createStreamDecode(); - char* const cmpBuf = malloc(LZ4_COMPRESSBOUND(messageMaxBytes)); - char* const decBuf = malloc(ringBufferBytes); + char* const cmpBuf = (char*) malloc(LZ4_COMPRESSBOUND(messageMaxBytes)); + char* const decBuf = (char*) malloc(ringBufferBytes); int decOffset = 0; for ( ; ; ) @@ -125,8 +125,8 @@ static int compare(FILE* f0, FILE* f1) { int result = 0; const size_t tempBufferBytes = 65536; - char* const b0 = malloc(tempBufferBytes); - char* const b1 = malloc(tempBufferBytes); + char* const b0 = (char*) malloc(tempBufferBytes); + char* const b1 = (char*) malloc(tempBufferBytes); while(0 == result) { |