summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2015-04-13 11:57:34 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2015-04-13 11:57:34 (GMT)
commitbc28fc1a0df8de9e9ec847430dae5873dac7a4d5 (patch)
treea3350fe9bcd7b9deb3b9d802d54350fc045a454c
parentda117257f5946295a379ca7ccf867c2854b0aed9 (diff)
parentfd77bad52f39106dc1af40405076581426e86877 (diff)
downloadlz4-bc28fc1a0df8de9e9ec847430dae5873dac7a4d5.zip
lz4-bc28fc1a0df8de9e9ec847430dae5873dac7a4d5.tar.gz
lz4-bc28fc1a0df8de9e9ec847430dae5873dac7a4d5.tar.bz2
Merge pull request #87 from t-mat/fix-example2
Replace obsolete functions in example code
-rw-r--r--examples/blockStreaming_doubleBuffer.c9
-rw-r--r--examples/blockStreaming_lineByLine.c12
2 files changed, 14 insertions, 7 deletions
diff --git a/examples/blockStreaming_doubleBuffer.c b/examples/blockStreaming_doubleBuffer.c
index 0adf6ae..58f2bdb 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>
@@ -50,8 +53,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_safe_continue(
+ lz4Stream, inpPtr, cmpBuf, inpBytes, sizeof(cmpBuf));
if(cmpBytes <= 0) {
break;
}
diff --git a/examples/blockStreaming_lineByLine.c b/examples/blockStreaming_lineByLine.c
index 6d14801..8ae268f 100644
--- a/examples/blockStreaming_lineByLine.c
+++ b/examples/blockStreaming_lineByLine.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>
@@ -38,7 +41,8 @@ static void test_compress(
size_t ringBufferBytes)
{
LZ4_stream_t* const lz4Stream = LZ4_createStream();
- char* const cmpBuf = malloc(LZ4_COMPRESSBOUND(messageMaxBytes));
+ const size_t cmpBufBytes = LZ4_COMPRESSBOUND(messageMaxBytes);
+ char* const cmpBuf = malloc(cmpBufBytes);
char* const inpBuf = malloc(ringBufferBytes);
int inpOffset = 0;
@@ -60,8 +64,8 @@ static void test_compress(
#endif
{
- const int cmpBytes = LZ4_compress_continue(
- lz4Stream, inpPtr, cmpBuf, inpBytes);
+ const int cmpBytes = LZ4_compress_safe_continue(
+ lz4Stream, inpPtr, cmpBuf, inpBytes, cmpBufBytes);
if (cmpBytes <= 0) break;
write_uint16(outFp, (uint16_t) cmpBytes);
write_bin(outFp, cmpBuf, cmpBytes);