summaryrefslogtreecommitdiffstats
path: root/examples/blockStreaming_doubleBuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/blockStreaming_doubleBuffer.c')
-rw-r--r--examples/blockStreaming_doubleBuffer.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/examples/blockStreaming_doubleBuffer.c b/examples/blockStreaming_doubleBuffer.c
index 0adf6ae..efe6fc6 100644
--- a/examples/blockStreaming_doubleBuffer.c
+++ b/examples/blockStreaming_doubleBuffer.c
@@ -2,7 +2,10 @@
// Copyright : Takayuki Matsuoka
-#define _CRT_SECURE_NO_WARNINGS // for MSVC
+#ifdef _MSC_VER /* Visual Studio */
+# define _CRT_SECURE_NO_WARNINGS
+# define snprintf sprintf_s
+#endif
#include "lz4.h"
#include <stdio.h>
@@ -35,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];
@@ -50,8 +55,8 @@ void test_compress(FILE* outFp, FILE* inpFp)
{
char cmpBuf[LZ4_COMPRESSBOUND(BLOCK_BYTES)];
- const int cmpBytes = LZ4_compress_continue(
- lz4Stream, inpPtr, cmpBuf, inpBytes);
+ const int cmpBytes = LZ4_compress_fast_continue(
+ lz4Stream, inpPtr, cmpBuf, inpBytes, sizeof(cmpBuf), 1);
if(cmpBytes <= 0) {
break;
}
@@ -68,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;